Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1372005

Re: [PATCH v3 06/10] sysctl: drop away useless label

From Andrew Morton <akpm@linux-foundation.org>
Newsgroups linux.kernel
Subject Re: [PATCH v3 06/10] sysctl: drop away useless label
Date 2016-04-06 00:20 +0200
Message-ID <rkHuh-2lA-1@gated-at.bofh.it> (permalink)
References <rkzGq-4wA-9@gated-at.bofh.it> <rkzGs-4wA-27@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Tue,  5 Apr 2016 16:56:15 +0300 Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:

> We have no locking in bin_uuid(). Thus, we may remove the out label and use
> return statements directly.
> 
> ...
>
> --- a/kernel/sysctl_binary.c
> +++ b/kernel/sysctl_binary.c
> @@ -1123,15 +1123,14 @@ static ssize_t bin_uuid(struct file *file,
>  
>  		result = kernel_read(file, 0, buf, sizeof(buf) - 1);
>  		if (result < 0)
> -			goto out;
> +			return result;
>  
>  		buf[result] = '\0';
>  
>  		/* Convert the uuid to from a string to binary */
>  		for (i = 0; i < 16; i++) {
> -			result = -EIO;
>  			if (!isxdigit(str[0]) || !isxdigit(str[1]))
> -				goto out;
> +				return -EIO;
>  
>  			uuid[i] = (hex_to_bin(str[0]) << 4) |
>  					hex_to_bin(str[1]);
> @@ -1143,15 +1142,12 @@ static ssize_t bin_uuid(struct file *file,
>  		if (oldlen > 16)
>  			oldlen = 16;
>  
> -		result = -EFAULT;
>  		if (copy_to_user(oldval, uuid, oldlen))
> -			goto out;
> +			return -EFAULT;
>  
>  		copied = oldlen;
>  	}
> -	result = copied;
> -out:
> -	return result;
> +	return copied;
>  }

Sure, but we may add locking or resource allocation in the future, in
which case this change will need to be undone.  I think it's better to
leave the code as-is.  It's presently quite typical kernel code.

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v3 00/10] uuid: convert users to generic UUID API Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2016-04-05 16:00 +0200
  [PATCH v3 03/10] lib/uuid: move generate_random_uuid() to uuid.c Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2016-04-05 16:00 +0200
  [PATCH v3 06/10] sysctl: drop away useless label Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2016-04-05 16:00 +0200
    Re: [PATCH v3 06/10] sysctl: drop away useless label Andrew Morton <akpm@linux-foundation.org> - 2016-04-06 00:20 +0200
      Re: [PATCH v3 06/10] sysctl: drop away useless label Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2016-04-06 13:40 +0200
  [PATCH v3 08/10] efi: redefine type, constant, macro from generic code Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2016-04-05 16:00 +0200
  [PATCH v3 02/10] ima: use %pU to output UUID in printable format Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2016-04-05 16:00 +0200
    Re: [PATCH v3 02/10] ima: use %pU to output UUID in printable format Joe Perches <joe@perches.com> - 2016-04-06 01:20 +0200
      Re: [PATCH v3 02/10] ima: use %pU to output UUID in printable format Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2016-04-06 13:10 +0200
  [PATCH v3 09/10] efivars: use generic UUID library Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2016-04-05 16:00 +0200
  [PATCH v3 07/10] sysctl: use generic UUID library Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2016-04-05 16:00 +0200
  [PATCH v3 04/10] lib/uuid: introduce few more generic helpers for UUID Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2016-04-05 16:00 +0200
    Re: [PATCH v3 04/10] lib/uuid: introduce few more generic helpers  for UUID Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2016-04-05 16:20 +0200

csiph-web