All of lore.kernel.org
 help / color / mirror / Atom feed
From: ebiederm@xmission.com (Eric W. Biederman)
To: Ben Hutchings <bhutchings@solarflare.com>
Cc: Stephen Hemminger <shemminger@vyatta.com>,
	<netdev@vger.kernel.org>, "Serge E. Hallyn" <serge@hallyn.com>
Subject: Re: [PATCH for 3.8] iproute2: Add "ip netns pids" and "ip netns identify"
Date: Thu, 17 Jan 2013 17:27:32 -0800	[thread overview]
Message-ID: <87mww71drv.fsf@xmission.com> (raw)
In-Reply-To: <1358470823.15692.156.camel@deadeye.wl.decadent.org.uk> (Ben Hutchings's message of "Fri, 18 Jan 2013 01:00:23 +0000")

Ben Hutchings <bhutchings@solarflare.com> writes:

> On Thu, 2013-01-17 at 16:23 -0800, Eric W. Biederman wrote:
>> Ben Hutchings <bhutchings@solarflare.com> writes:
>> 
>> > On Mon, 2012-11-26 at 17:16 -0600, Eric W. Biederman wrote:
> [...]
>> >> --- a/ip/ipnetns.c
>> >> +++ b/ip/ipnetns.c
> [...]
>> >> +static int is_pid(const char *str)
>> >> +{
>> >> +	int ch;
>> >> +	for (; (ch = *str); str++) {
>> >> +		if (!isdigit(ch))
>> >
>> > ch must be cast to unsigned char before passing to isdigit().
>> 
>> isdigit is defined to take an int.  A legacy of the implicit casts in
>> the K&R C days.  Casting to unsigned char would be pointless and silly.
> [...]
>
> It's not pointless.  This is explained in the very first line of the
> description in the manual page...

If it's not pointless it is an implementation bug.  The conversion to of
char to int happens implicitly whenever you pass a char.  It is
absolutely broken to have a function that takes a char converted to int
and reject the automatic conversion of char to int.

I suspect much more strongly that it is a case of poor documentation.

If isdigit can't deal with what I have passed it I will be much more
interested in writing a patch for isdigit.

That said I just dobule checked with the code below.  Negative character
values work correctly and don't cause any runtime errors.

It looks like it is time to update the manpage to remove that
confusing/wrong sentence.

Eric

#include <ctype.h>
#include <limits.h>
#include <stdio.h>

int main(int argc, char **argv)
{
	char c;
	for (c = CHAR_MIN; c < CHAR_MAX; c++) {
		printf("c: %d isdigit: %d\n",
		       c, isdigit(c));
	}
	return 0;
}

  reply	other threads:[~2013-01-18  1:27 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-26 23:16 [PATCH for 3.8] iproute2: Add "ip netns pids" and "ip netns identify" Eric W. Biederman
2012-11-27 18:00 ` Ben Hutchings
2013-01-18  0:23   ` Eric W. Biederman
2013-01-18  1:00     ` Ben Hutchings
2013-01-18  1:27       ` Eric W. Biederman [this message]
2013-01-18  9:41         ` David Laight
2013-01-18 13:53         ` Ben Hutchings
2013-01-18 18:49           ` Eric W. Biederman
2013-01-21  9:52             ` David Laight
2013-01-18  0:44   ` [PATCH iproute-3.8 0/6] ip netns bug fixes and enhancements Eric W. Biederman
2013-01-18  0:45     ` [PATCH iproute2-3.8 1/6] iproute2: Don't propogate mounts out of ip Eric W. Biederman
2013-01-18  0:46     ` [PATCH iproute2-3.8 2/6] iproute2: Normalize return codes in "ip netns" Eric W. Biederman
2013-01-18  0:46     ` [PATCH iproute2-3.8 3/6] iproute2: Improve "ip netns add" failure error message Eric W. Biederman
2013-01-18  0:47     ` [PATCH iproute2-3.8 4/6] iproute2: Make "ip netns delete" more likely to succeed Eric W. Biederman
2013-01-18  0:47     ` [PATCH iproute2-3.8 5/6] iproute2: Fill in the ip-netns.8 manpage Eric W. Biederman
2013-01-18  0:48     ` [PATCH iproute2-3.8 6/6] iproute2: Add "ip netns pids" and "ip netns identify" Eric W. Biederman
2013-02-07  0:56     ` [PATCH iproute-3.8 0/6] ip netns bug fixes and enhancements Vijay Subramanian
2013-02-07  8:57       ` Eric W. Biederman
2013-02-07 18:17         ` Vijay Subramanian

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=87mww71drv.fsf@xmission.com \
    --to=ebiederm@xmission.com \
    --cc=bhutchings@solarflare.com \
    --cc=netdev@vger.kernel.org \
    --cc=serge@hallyn.com \
    --cc=shemminger@vyatta.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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.