From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 9DA1E429E25 for ; Sat, 29 Oct 2011 13:08:13 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WhnSvAJplHnE for ; Sat, 29 Oct 2011 13:08:12 -0700 (PDT) Received: from mail-fx0-f53.google.com (mail-fx0-f53.google.com [209.85.161.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 76DE7431FB6 for ; Sat, 29 Oct 2011 13:08:12 -0700 (PDT) Received: by faai28 with SMTP id i28so5095151faa.26 for ; Sat, 29 Oct 2011 13:08:11 -0700 (PDT) Received: by 10.223.75.25 with SMTP id w25mr16506546faj.15.1319918889247; Sat, 29 Oct 2011 13:08:09 -0700 (PDT) Received: from localhost (dsl-hkibrasgw4-fe5cdc00-23.dhcp.inet.fi. [80.220.92.23]) by mx.google.com with ESMTPS id y2sm26353665fag.12.2011.10.29.13.08.05 (version=SSLv3 cipher=OTHER); Sat, 29 Oct 2011 13:08:07 -0700 (PDT) From: Jani Nikula To: Daniel Schoepe , notmuch@notmuchmail.org Subject: Re: [RFC PATCH 2/3] cli: add support for limiting the number of search results In-Reply-To: <87mxcjk8mt.fsf@gilead.invalid> References: <87mxcjk8mt.fsf@gilead.invalid> User-Agent: Notmuch/0.9-20-gc4362a8 (http://notmuchmail.org) Emacs/23.3.1 (i686-pc-linux-gnu) Date: Sat, 29 Oct 2011 23:08:04 +0300 Message-ID: <878vo3r26z.fsf@nikula.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: amdragon@mit.edu X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 29 Oct 2011 20:08:13 -0000 On Sat, 29 Oct 2011 19:30:50 +0200, Daniel Schoepe wrote: > On Fri, 28 Oct 2011 23:59:30 +0300, Jani Nikula 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.