[Bug 647] removal of (most likely) useless unsigned comparisons

bugzilla at busybox.net bugzilla at busybox.net
Sat Oct 3 23:12:30 UTC 2009


https://bugs.busybox.net/show_bug.cgi?id=647





--- Comment #1 from Denys Vlasenko <vda.linux at googlemail.com>  2009-10-03 23:12:29 UTC ---
applied, thanks!

in ah, the code can be shrank there by using bb_strtou[l[ll]]:

-                       val = (rlim_t) 0;
-
-                       while ((c = *p++) >= '0' && c <= '9') {
-                               val = (val * 10) + (long)(c - '0');
-                               // val is actually 'unsigned long int' and
can't get < 0
-                               if (val < (rlim_t) 0)
-                                       break;
-                       }
-                       if (c)
+                       if (sizeof(val) == sizeof(int))
+                               val = bb_strtou(p, NULL, 10);
+                       else if (sizeof(val) == sizeof(long))
+                               val = bb_strtoul(p, NULL, 10);
+                       else
+                               val = bb_strtoull(p, NULL, 10);
+                       if (errno)
                                ash_msg_and_raise_error("bad number");


-- 
Configure bugmail: https://bugs.busybox.net/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


More information about the busybox-cvs mailing list