[RFC PATCH 2/3] cli: add support for limiting the number of search results

Jani Nikula jani at nikula.org
Sat Oct 29 13:08:04 PDT 2011


On Sat, 29 Oct 2011 19:30:50 +0200, Daniel Schoepe <daniel at schoepe.org> wrote:
> On Fri, 28 Oct 2011 23:59:30 +0300, Jani Nikula <jani at nikula.org> wrote:
> > @@ -412,6 +413,14 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
> >  		fprintf (stderr, "Invalid value for --sort: %s\n", opt);
> >  		return 1;
> >  	    }
> > +	} else if (STRNCMP_LITERAL (argv[i], "--maxitems=") == 0) {
> > +	    const char *p;
> > +	    opt = argv[i] + sizeof ("--maxitems=") - 1;
> > +	    maxitems = strtoul(opt, &p, 10);
> 
> p should be of type `char *', not `const char *', as it will be
> modified by strtoul. (Otherwise, gcc will produce a warning about this).

strtoul() won't touch the data pointed to by p (it only modifies p), so
in that sense it could be const, but you're right in that it really
should be 'char *', just for a more complicated reason. Thanks for
making me look it up: http://c-faq.com/ansi/constmismatch.html (not the
best of explanations, perhaps, but gives an idea why the 2nd parameter
of strtoul() can't be 'const char **').

BR,
Jani.


More information about the notmuch mailing list