From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jeff Garzik Subject: Re: [PATCH hail] const-correctness tweaks Date: Tue, 19 Oct 2010 18:24:34 -0400 Message-ID: <4CBE1AA2.5020004@garzik.org> References: <87mxqro78a.fsf@meyering.net> Mime-Version: 1.0 Content-Transfer-Encoding: QUOTED-PRINTABLE Return-path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:message-id:date:from :user-agent:mime-version:to:cc:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=cpkeyDtIiexfyF3vSFkTI0tbg6Ph3KQugc+045xOyXI=; b=Ekk67JAjCTA3psP6l0xuji7dvw4zrU0g/ncRUQNYQILNFjjcAdTis49IMRH66TK2Lz Rl+6D7z4ZjIB2H3YaCUCTE05YkE1ff6bGu0d156yn0GSRGd1M1SsSTN3N0vHmPwlbGmX ZWOgE7xiMy1jFFIaKfrl+oX1RrkbSq5UG4fJM= In-Reply-To: <87mxqro78a.fsf@meyering.net> Sender: hail-devel-owner@vger.kernel.org List-ID: Content-Type: text/plain; charset="windows-1252"; format="flowed" To: Jim Meyering Cc: Project Hail On 10/06/2010 08:07 AM, Jim Meyering wrote: > > Make write_cb callback's buffer parameter const, like all write-like > functions. > Give a few "char *" parameters the "const" attribute. > > Signed-off-by: Jim Meyering > --- > > It looks like most of hail's interfaces are const-correct, > but one stood out because it provokes a warning when I tried to > pass a const-correct write_cb function to hstor_get from iwhd: > > proxy.c:382: warning: passing argument 4 of 'hstor_get' from \ > incompatible pointer type > /usr/include/hstor.h:173: note: expected \ > 'size_t (*)(void *, size_t, size_t, void *)' but argument is = of type \ > 'size_t (*)(const void *, size_t, size_t, void *)' > > In case you feel comfortable fixing this, here's a patch: Sorry for not getting back to this; I had hoped to solve some additiona= l=20 problems that cropped up, but didn't have time. So, to forestall=20 further delay, libtool: compile: gcc -DHAVE_CONFIG_H -I. -I.. -I../include -pthread=20 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include=20 -I/usr/include/libxml2 -O2 -Wall -Wshadow -g -MT hutil.lo -MD -MP -MF=20 =2Edeps/hutil.Tpo -c hutil.c -o hutil.o hutil.c: In function =91hreq_hdr_push=92: hutil.c:145: warning: assignment discards qualifiers from pointer targe= t=20 type hutil.c:146: warning: assignment discards qualifiers from pointer targe= t=20 type warnings appear after this patch. When solving these warnings with=20 'const' markers, it quickly becomes a bit of a rat's nest. At a minimum, the write_cb callback signature must match libcurl's,=20 which does not use 'const'. I can see this makes sense from libcurl=20 implementation's perspective, even if it does not really match the=20 constness one expects from a foo-get function. Jeff