diff options
author | Joe Perches <joe@perches.com> | 2017-02-08 06:33:36 -0500 |
---|---|---|
committer | Boris Ostrovsky <boris.ostrovsky@oracle.com> | 2017-02-08 10:09:09 -0500 |
commit | c0d197d55e8e8aeeea55f79bdf67e1c957bfa25d (patch) | |
tree | 7edcfb440ddbb1c578ba31c2b43cc8bbbc034dcf | |
parent | 7a1c44ebc5ac2e2c28d95b0da6060728c334e7e4 (diff) |
xenbus: Neaten xenbus_va_dev_error
This function error patch can be simplified, so do so.
Remove fail: label and somewhat obfuscating, used once "error_path"
function.
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
-rw-r--r-- | drivers/xen/xenbus/xenbus_client.c | 39 |
1 files changed, 10 insertions, 29 deletions
diff --git a/drivers/xen/xenbus/xenbus_client.c b/drivers/xen/xenbus/xenbus_client.c index 056da6ee1a35..915d77785193 100644 --- a/drivers/xen/xenbus/xenbus_client.c +++ b/drivers/xen/xenbus/xenbus_client.c | |||
@@ -259,53 +259,34 @@ int xenbus_frontend_closed(struct xenbus_device *dev) | |||
259 | } | 259 | } |
260 | EXPORT_SYMBOL_GPL(xenbus_frontend_closed); | 260 | EXPORT_SYMBOL_GPL(xenbus_frontend_closed); |
261 | 261 | ||
262 | /** | ||
263 | * Return the path to the error node for the given device, or NULL on failure. | ||
264 | * If the value returned is non-NULL, then it is the caller's to kfree. | ||
265 | */ | ||
266 | static char *error_path(struct xenbus_device *dev) | ||
267 | { | ||
268 | return kasprintf(GFP_KERNEL, "error/%s", dev->nodename); | ||
269 | } | ||
270 | |||
271 | |||
272 | static void xenbus_va_dev_error(struct xenbus_device *dev, int err, | 262 | static void xenbus_va_dev_error(struct xenbus_device *dev, int err, |
273 | const char *fmt, va_list ap) | 263 | const char *fmt, va_list ap) |
274 | { | 264 | { |
275 | unsigned int len; | 265 | unsigned int len; |
276 | char *printf_buffer = NULL; | 266 | char *printf_buffer; |
277 | char *path_buffer = NULL; | 267 | char *path_buffer; |
278 | 268 | ||
279 | #define PRINTF_BUFFER_SIZE 4096 | 269 | #define PRINTF_BUFFER_SIZE 4096 |
270 | |||
280 | printf_buffer = kmalloc(PRINTF_BUFFER_SIZE, GFP_KERNEL); | 271 | printf_buffer = kmalloc(PRINTF_BUFFER_SIZE, GFP_KERNEL); |
281 | if (printf_buffer == NULL) | 272 | if (!printf_buffer) |
282 | goto fail; | 273 | return; |
283 | 274 | ||
284 | len = sprintf(printf_buffer, "%i ", -err); | 275 | len = sprintf(printf_buffer, "%i ", -err); |
285 | vsnprintf(printf_buffer+len, PRINTF_BUFFER_SIZE-len, fmt, ap); | 276 | vsnprintf(printf_buffer + len, PRINTF_BUFFER_SIZE - len, fmt, ap); |
286 | 277 | ||
287 | dev_err(&dev->dev, "%s\n", printf_buffer); | 278 | dev_err(&dev->dev, "%s\n", printf_buffer); |
288 | 279 | ||
289 | path_buffer = error_path(dev); | 280 | path_buffer = kasprintf(GFP_KERNEL, "error/%s", dev->nodename); |
290 | 281 | if (!path_buffer || | |
291 | if (path_buffer == NULL) { | 282 | xenbus_write(XBT_NIL, path_buffer, "error", printf_buffer)) |
292 | dev_err(&dev->dev, "failed to write error node for %s (%s)\n", | 283 | dev_err(&dev->dev, "failed to write error node for %s (%s)\n", |
293 | dev->nodename, printf_buffer); | 284 | dev->nodename, printf_buffer); |
294 | goto fail; | ||
295 | } | ||
296 | 285 | ||
297 | if (xenbus_write(XBT_NIL, path_buffer, "error", printf_buffer) != 0) { | ||
298 | dev_err(&dev->dev, "failed to write error node for %s (%s)\n", | ||
299 | dev->nodename, printf_buffer); | ||
300 | goto fail; | ||
301 | } | ||
302 | |||
303 | fail: | ||
304 | kfree(printf_buffer); | 286 | kfree(printf_buffer); |
305 | kfree(path_buffer); | 287 | kfree(path_buffer); |
306 | } | 288 | } |
307 | 289 | ||
308 | |||
309 | /** | 290 | /** |
310 | * xenbus_dev_error | 291 | * xenbus_dev_error |
311 | * @dev: xenbus device | 292 | * @dev: xenbus device |