Re: [PATCH] kernel 2.5.5 - coredump sysctl

From: Michael Sinz (msinz@wgate.com)
Date: Thu Feb 21 2002 - 10:41:37 EST


Alan Cox wrote:
>
> Would it be cleaner to use snprintf here ? Each of those checks you do
> appears to come down to
>
> buf+=snprintf(buf, sizeof(buffer)+buffer-buf, "%foo", arg)

        buf+=snprintf(buf, MAX_CORE_NAME - buf, "%foo", arg)

Hmm.... I was trying to keep things clear but if snprintf() is what
is prefered, it could be done so. Most of the items here are just
string copies anyway, so the loop is trivial (and snprintf is
much higher overhead)

snprintf is a bit more annoying due to the fact that snprintf returns
the number of bytes that *would have been written* and not the number
of bytes actually written if the limit is reached. (Or, in older C
libraries, it returns -1 if the limit is hit)

(Don't complain to me that snprintf() is like that, it is C99 standard.
Older glibc have the -1 return code, which is also not really want
you want.)

BTW - I would really like to see this in the 2.4 kernels too - our
clusters really could use it (and do use it since I build the kernel
we use).

-- 
Michael Sinz -- msinz@wgate.com -- http://www.sinz.org
A master's secrets are only as good as
        the master's ability to explain them to others.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Feb 23 2002 - 21:00:34 EST