coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Z and Y suffixes in xstrtol.c


From: Paul Eggert
Subject: Re: Z and Y suffixes in xstrtol.c
Date: Tue, 16 Dec 2014 09:05:14 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0

On 12/16/2014 05:46 AM, Pádraig Brady wrote:
          if (xstrtoul (optarg, NULL, 10, &val, "") != LONGINT_OK
-            || MIN (INT_MAX, SIZE_MAX) < val)
-          error (EXIT_FAILURE, 0, _("%s: invalid number"), optarg);
+            || (MIN (INT_MAX, SIZE_MAX) < val && (errno = EOVERFLOW)))
+          error (EXIT_FAILURE, errno, _("invalid number %s"), quote (optarg));

I'm afraid I find this sort of code hard to read, due to the side effect withinn an 'if' expression. The GNU coding standards say "Try to avoid assignments inside if-conditions (assignments inside while-conditions are ok)." <https://www.gnu.org/prep/standards/html_node/Syntactic-Conventions.html> Can you please redo the patch to avoid this sort of thing? Perhaps with a wrapper around xstrtoul? Thanks.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]