From: tedu Date: Wed, 27 Jul 2016 01:52:03 +0000 (+0000) Subject: fix signed char extension bugs. from fade@cock.li. ok guenther. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=7be2669572f77d241ef6195471f504253d20a78a;p=openbsd fix signed char extension bugs. from fade@cock.li. ok guenther. As a personal remark, I'll add that it's not necessary to cast a value to a function's return type. The compiler is happy to do that for you. But such casts can hide warnings and bugs. --- diff --git a/usr.bin/printf/printf.c b/usr.bin/printf/printf.c index 73eb5b28cbb..c0a76f04859 100644 --- a/usr.bin/printf/printf.c +++ b/usr.bin/printf/printf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: printf.c,v 1.24 2015/10/09 01:37:08 deraadt Exp $ */ +/* $OpenBSD: printf.c,v 1.25 2016/07/27 01:52:03 tedu Exp $ */ /* * Copyright (c) 1989 The Regents of the University of California. @@ -439,7 +439,7 @@ getlong(void) return(0L); if (**gargv == '\"' || **gargv == '\'') - return (long) *((*gargv++)+1); + return (unsigned char) *((*gargv++)+1); errno = 0; val = strtol (*gargv, &ep, 0); @@ -457,7 +457,7 @@ getulong(void) return(0UL); if (**gargv == '\"' || **gargv == '\'') - return (unsigned long) *((*gargv++)+1); + return (unsigned char) *((*gargv++)+1); errno = 0; val = strtoul (*gargv, &ep, 0); @@ -475,7 +475,7 @@ getdouble(void) return(0.0); if (**gargv == '\"' || **gargv == '\'') - return (double) *((*gargv++)+1); + return (unsigned char) *((*gargv++)+1); errno = 0; val = strtod (*gargv, &ep);