lkml.org 
[lkml]   [2015]   [May]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2/3] string: provide strscpy() and strscpy_truncate()
On Wed, May 06, 2015 at 06:45:56PM +0200, Geert Uytterhoeven wrote:
> On Wed, May 6, 2015 at 5:59 PM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> > We actually do have a __must_check tag so it's easy enough to force
> > people to check. A different option is we could make it trigger a
>
> People tend to ignore compiler warnings...

We're doing a lot better these days with zero day build testing. There
is not even one ignored __must_check return in my allmodconfig.

>
> > WARN_ONCE().
> >
> > #define strXcpy(dest, src, len) (({ \
> > ssize_t __ret = strscpy_truncate(dest, src, len); \
> > WARN_ONCE(__ret < 0, "strXcpy trancates\n"); \
> > __ret; }))
>
> Which will probably trigger only in extreme cases in the wild, not during
> development.

It's less subtle than just putting an empty string there so we're more
likely to get bug reports than with the original code.

regards,
dan carpenter


\
 
 \ /
  Last update: 2015-05-07 11:21    [W:0.846 / U:0.968 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site