Bug 647 - removal of (most likely) useless unsigned comparisons
Summary: removal of (most likely) useless unsigned comparisons
Status: RESOLVED FIXED
Alias: None
Product: Busybox
Classification: Unclassified
Component: Other (show other bugs)
Version: unspecified
Hardware: All All
: P5 enhancement
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-10-03 13:57 UTC by Jiri J.
Modified: 2009-10-08 00:13 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments
patch: remove two unneeded unsigned comparison cases (952 bytes, patch)
2009-10-03 13:57 UTC, Jiri J.
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jiri J. 2009-10-03 13:57:50 UTC
Created attachment 683 [details]
patch: remove two unneeded unsigned comparison cases

I've run across some gcc warnings which included these things.
It would be probably better to either remove them or replace with their signed counterparts.

Patch attached.
Comment 1 Denys Vlasenko 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");