From: Jens Axboe <axboe@kernel.dk>
To: Nicholas Krause <xerofoify@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] block:Add proper error handling to the function, disk_add_events
Date: Thu, 14 May 2015 21:22:22 -0400 [thread overview]
Message-ID: <55554A4E.6040401@kernel.dk> (raw)
In-Reply-To: <1431647831-14991-1-git-send-email-xerofoify@gmail.com>
On 05/14/2015 07:57 PM, Nicholas Krause wrote:
> This adds the proper required error checking to the function,
> disk_add_events for when there are no disk events by returning
> the error code, -EBUSY. Further this also adds error checking
> for when our call to the function, sysfs_create_files by making
> this function's return now go into a newly declared variable,
> ret and at the end of this function's body return it to indicate
> whether this function is successful or not to the caller.
>
> Signed-off-by: Nicholas Krause <xerofoify@gmail.com>
> ---
> block/genhd.c | 13 +++++++++----
> 1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/block/genhd.c b/block/genhd.c
> index 0a536dc..3eb7ee9 100644
> --- a/block/genhd.c
> +++ b/block/genhd.c
> @@ -1803,15 +1803,19 @@ static void disk_alloc_events(struct gendisk *disk)
> disk->ev = ev;
> }
>
> -static void disk_add_events(struct gendisk *disk)
> +static int disk_add_events(struct gendisk *disk)
> {
> + int ret = 0;
> if (!disk->ev)
> - return;
> + return -EBUSY;
> +
> + ret = sysfs_create_files(&disk_to_dev(disk)->kobj, disk_events_attrs)
>
> - /* FIXME: error handling */
> - if (sysfs_create_files(&disk_to_dev(disk)->kobj, disk_events_attrs) < 0)
> + if (!ret) {
> pr_warn("%s: failed to create sysfs files for events\n",
> disk->disk_name);
> + return ret;
> + }
You didn't even test this, obviously.
--
Jens Axboe
next parent reply other threads:[~2015-05-15 1:22 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1431647831-14991-1-git-send-email-xerofoify@gmail.com>
2015-05-15 1:22 ` Jens Axboe [this message]
[not found] ` <4B7B2C3D-04EE-49BF-86B1-0C84BBB62E54@gmail.com>
2015-05-15 1:41 ` [PATCH] block:Add proper error handling to the function, disk_add_events Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=55554A4E.6040401@kernel.dk \
--to=axboe@kernel.dk \
--cc=linux-kernel@vger.kernel.org \
--cc=xerofoify@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox