From: Morten Welinder <mwelinder@gmail.com>
To: GIT Mailing List <git@vger.kernel.org>
Subject: Usage of isspace and friends
Date: Tue, 11 Oct 2005 21:40:26 -0400 [thread overview]
Message-ID: <118833cc0510111840k715e1190l54ad65f821c77848@mail.gmail.com> (raw)
Someone needs to audit the usage of isspace, tolower, and friends. There are
things like this in the code:
static int is_dev_null(const char *str)
{
return !memcmp("/dev/null", str, 9) && isspace(str[9]);
}
Since str[9] is of type char it should not be used as a argument to
isspace directly,
but rather be cast to unsigned char:
... isspace((unsigned char)str[9]);
Admittedly that is ugly. Blame K&R. (Glibc has a partial workaround for this
kind of coding bug. On the up side you won't get a crash, but on the down
side you can get the wrong result.)
Morten
next reply other threads:[~2005-10-13 3:30 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-10-12 1:40 Morten Welinder [this message]
2005-10-13 6:49 ` Usage of isspace and friends Junio C Hamano
2005-10-13 8:29 ` Antti-Juhani Kaijanaho
2005-10-13 13:27 ` H. Peter Anvin
2005-10-13 15:44 ` Junio C Hamano
2005-10-13 15:04 ` Linus Torvalds
2005-10-13 15:45 ` H. Peter Anvin
2005-10-13 15:56 ` Linus Torvalds
2005-10-13 16:07 ` H. Peter Anvin
2005-10-13 15:46 ` Linus Torvalds
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=118833cc0510111840k715e1190l54ad65f821c77848@mail.gmail.com \
--to=mwelinder@gmail.com \
--cc=git@vger.kernel.org \
/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.
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).