mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Szabolcs Nagy <nsz@port70.net>
To: musl@lists.openwall.com
Subject: Re: minor fixes
Date: Mon, 26 Sep 2011 19:07:34 +0200	[thread overview]
Message-ID: <20110926170734.GC24939@port70.net> (raw)
In-Reply-To: <20110925134725.GA24939@port70.net>

[-- Attachment #1: Type: text/plain, Size: 266 bytes --]

a pedantic ctype macro fix: move the unsigned cast inside

i can think of one case where it matters:
if EOF was defined as INT_MIN then
(unsigned)(a - 'c') can overflow while ((unsigned)a - 'c') is ok

(i know this is pathological and EOF is actually defined as -1)

[-- Attachment #2: ctype_cast.diff --]
[-- Type: text/x-diff, Size: 798 bytes --]

diff --git a/include/ctype.h b/include/ctype.h
index 97b9737..a605d08 100644
--- a/include/ctype.h
+++ b/include/ctype.h
@@ -16,12 +16,12 @@ int   isxdigit(int);
 int   tolower(int);
 int   toupper(int);
 
-#define isalpha(a) ((unsigned)(((a)|32)-'a') < 26)
-#define isdigit(a) ((unsigned)((a)-'0') < 10)
-#define islower(a) ((unsigned)((a)-'a') < 26)
-#define isupper(a) ((unsigned)((a)-'A') < 26)
-#define isprint(a) ((unsigned)((a)-0x20) < 0x5f)
-#define isgraph(a) ((unsigned)((a)-0x21) < 0x5e)
+#define isalpha(a) ((((unsigned)(a)|32)-'a') < 26)
+#define isdigit(a) (((unsigned)(a)-'0') < 10)
+#define islower(a) (((unsigned)(a)-'a') < 26)
+#define isupper(a) (((unsigned)(a)-'A') < 26)
+#define isprint(a) (((unsigned)(a)-0x20) < 0x5f)
+#define isgraph(a) (((unsigned)(a)-0x21) < 0x5e)
 
 
 

      parent reply	other threads:[~2011-09-26 17:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-25 13:47 Szabolcs Nagy
2011-09-25 16:14 ` Rich Felker
2011-09-26 17:07 ` Szabolcs Nagy [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110926170734.GC24939@port70.net \
    --to=nsz@port70.net \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).