Source-Changes-D archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src/lib/libc/string

On Fri, Nov 25, 2011 at 05:40:51PM +0100, Joerg Sonnenberger wrote:
 > > And why should the/any static analyzer have to figure that out when
 > > coding it right makes it a nonissue?
 > Because that's what is making warnings useful. To not complain about
 > non-issues.

Like this?

   const char *
   foo(const char *s)
           size_t len;
           char *t;

           len = strlen(s);
           if (len >= 2 && s[0] == s[len-1]) {
                   t = s+1;
           } else {
                   t = s;
           return strchr(t, '"');

We require that this be written with a "const" on t, even though it's
a "non-issue". Part of the price of checking is the obligation to
provide code that has the details right.

David A. Holland

Home | Main Index | Thread Index | Old Index