X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Fopt%2Fhelpers.c;h=420a97a4fcac596fd31999ffbda42bb229a7f0f3;hb=cf1b26db4b43f3e5a4448abcd45c424cc2207928;hp=dfeb4e2e790a553173830d039ae84b8026df2fa8;hpb=ac9d55d8c5af9697be8c4dd4f27de61e3cb8bf95;p=ccan diff --git a/ccan/opt/helpers.c b/ccan/opt/helpers.c index dfeb4e2e..420a97a4 100644 --- a/ccan/opt/helpers.c +++ b/ccan/opt/helpers.c @@ -258,7 +258,8 @@ static char * set_long_with_suffix(const char *arg, long *l, const long base) return err; *l = ll; - if (*l != ll) + /* Beware truncation, but don't generate untestable code. */ + if (sizeof(*l) != sizeof(ll) && *l != ll) return arg_bad("value '%s' does not fit into a long", arg); return NULL; } @@ -272,7 +273,8 @@ static char * set_ulong_with_suffix(const char *arg, unsigned long *ul, const lo if (ll < 0) return arg_bad("'%s' is negative but destination is unsigned", arg); *ul = ll; - if (*ul != ll) + /* Beware truncation, but don't generate untestable code. */ + if (sizeof(*ul) != sizeof(ll) && *ul != ll) return arg_bad("value '%s' does not fit into an unsigned long", arg); return NULL; }