| Summary: | removal of (most likely) useless unsigned comparisons | ||
|---|---|---|---|
| Product: | Busybox | Reporter: | Jiri J. <jirij.jabb> |
| Component: | Other | Assignee: | unassigned |
| Status: | RESOLVED FIXED | ||
| Severity: | enhancement | CC: | busybox-cvs |
| Priority: | P5 | ||
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | All | ||
| Host: | Target: | ||
| Build: | |||
| Attachments: | patch: remove two unneeded unsigned comparison cases | ||
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");
|
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.