Commit 4aa735b2 authored by Martin Storsjö's avatar Martin Storsjö

Cast the output from strtoul to unsigned int

On platforms where unsigned long is 64 bit, the implicit conversion
to unsigned int can warn if such warnings are enabled.

Add casts to incidate that this is known/intended.
parent e3d028fb
......@@ -521,7 +521,7 @@ int main(int argc, char *argv[]) {
fprintf(stderr, "]\n");
return 0;
} else {
state.seed = strtoul(argv[1], NULL, 10);
state.seed = (unsigned int) strtoul(argv[1], NULL, 10);
}
argc--;
......
......@@ -134,7 +134,7 @@ static void error(const char *const app, const char *const optarg,
static unsigned parse_unsigned(char *optarg, const int option, const char *app) {
char *end;
const unsigned res = strtoul(optarg, &end, 0);
const unsigned res = (unsigned) strtoul(optarg, &end, 0);
if (*end || end == optarg) error(app, optarg, option, "an integer");
return res;
}
......@@ -193,9 +193,9 @@ static unsigned parse_enum(char *optarg, const EnumParseTable *const tbl,
char *end;
unsigned res;
if (!strncmp(optarg, "0x", 2)) {
res = strtoul(&optarg[2], &end, 16);
res = (unsigned) strtoul(&optarg[2], &end, 16);
} else {
res = strtoul(optarg, &end, 0);
res = (unsigned) strtoul(optarg, &end, 0);
}
if (*end || end == optarg) {
......
......@@ -230,7 +230,7 @@ static int md5_verify(MD5Context *const md5, const char *const md5_str) {
char *ignore;
memcpy(t, p, 2);
p += 2;
val = strtoul(t, &ignore, 16);
val = (unsigned) strtoul(t, &ignore, 16);
abcd[i] |= val << (8 * j);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment