From owner-svn-src-all@FreeBSD.ORG Fri Jun 8 17:30:17 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 35F461065677; Fri, 8 Jun 2012 17:30:17 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from server.mypc.hu (server.mypc.hu [87.229.73.95]) by mx1.freebsd.org (Postfix) with ESMTP id 9B2F38FC20; Fri, 8 Jun 2012 17:30:16 +0000 (UTC) Received: from server.mypc.hu (localhost [127.0.0.1]) by server.mypc.hu (Postfix) with ESMTP id CA36314E7912; Fri, 8 Jun 2012 19:30:09 +0200 (CEST) X-Virus-Scanned: amavisd-new at server.mypc.hu Received: from server.mypc.hu ([127.0.0.1]) by server.mypc.hu (server.mypc.hu [127.0.0.1]) (amavisd-new, port 10024) with LMTP id CHuSWC1Ob0Xh; Fri, 8 Jun 2012 19:30:08 +0200 (CEST) Received: from [192.168.1.117] (catv-80-98-232-12.catv.broadband.hu [80.98.232.12]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by server.mypc.hu (Postfix) with ESMTPSA id C68C214E78B1; Fri, 8 Jun 2012 19:30:08 +0200 (CEST) Message-ID: <4FD2369D.6040503@FreeBSD.org> Date: Fri, 08 Jun 2012 19:30:05 +0200 From: Gabor Kovesdan User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20120410 Thunderbird/13.0a2 MIME-Version: 1.0 To: Dimitry Andric References: <201206081708.q58H8RRw072192@svn.freebsd.org> In-Reply-To: <201206081708.q58H8RRw072192@svn.freebsd.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r236759 - head/usr.bin/sort X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Jun 2012 17:30:17 -0000 On 2012.06.08. 19:08, Dimitry Andric wrote: > In usr.bin/sort, use another method of silencing warnings about unused > arguments, which does not trigger self-assignment warnings in certain > circumstances (for example, using clang with ccache). > > MFC after: 3 days > > Modified: > head/usr.bin/sort/sort.h > > Modified: head/usr.bin/sort/sort.h > ============================================================================== > --- head/usr.bin/sort/sort.h Fri Jun 8 16:16:03 2012 (r236758) > +++ head/usr.bin/sort/sort.h Fri Jun 8 17:08:27 2012 (r236759) > @@ -41,7 +41,7 @@ > > #define VERSION "2.3-FreeBSD" > > -#define UNUSED_ARG(A) do { A=A; } while(0) > +#define UNUSED_ARG(A) do { (void)(A); } while(0) My fault, I should have fixed this. But what about this version? I think it is more elegant and this is how it should have been done initially: Index: coll.c =================================================================== --- coll.c (revision 236759) +++ coll.c (working copy) @@ -792,7 +792,8 @@ * Implements numeric sort for -n and -h. */ static int -numcoll_impl(struct key_value *kv1, struct key_value *kv2, size_t offset, bool use_suffix) +numcoll_impl(struct key_value *kv1, struct key_value *kv2, + size_t offset __unused, bool use_suffix) { struct bwstring *s1, *s2; wchar_t sfrac1[MAX_NUM_SIZE + 1], sfrac2[MAX_NUM_SIZE + 1]; @@ -810,8 +811,6 @@ cmp_res = 0; key1_read = key2_read = false; - UNUSED_ARG(offset); - if (debug_sort) { bwsprintf(stdout, s1, "; k1=<", ">"); bwsprintf(stdout, s2, ", k2=<", ">"); @@ -968,14 +967,13 @@ * Implements random sort (-R). */ static int -randomcoll(struct key_value *kv1, struct key_value *kv2, size_t offset) +randomcoll(struct key_value *kv1, struct key_value *kv2, + size_t offset __unused) { struct bwstring *s1, *s2; MD5_CTX ctx1, ctx2; char *b1, *b2; - UNUSED_ARG(offset); - s1 = kv1->k; s2 = kv2->k; @@ -1022,12 +1020,11 @@ * Implements version sort (-V). */ static int -versioncoll(struct key_value *kv1, struct key_value *kv2, size_t offset) +versioncoll(struct key_value *kv1, struct key_value *kv2, + size_t offset __unused) { struct bwstring *s1, *s2; - UNUSED_ARG(offset); - s1 = kv1->k; s2 = kv2->k; @@ -1098,7 +1095,7 @@ * Implements general numeric sort (-g). */ static int -gnumcoll(struct key_value *kv1, struct key_value *kv2, size_t offset) +gnumcoll(struct key_value *kv1, struct key_value *kv2, size_t offset __unused) { double d1, d2; int err1, err2; @@ -1108,8 +1105,6 @@ err1 = err2 = 0; key1_read = key2_read = false; - UNUSED_ARG(offset); - if (debug_sort) { bwsprintf(stdout, kv1->k, "; k1=<", ">"); bwsprintf(stdout, kv2->k, "; k2=<", ">"); @@ -1256,7 +1251,7 @@ * Implements month sort (-M). */ static int -monthcoll(struct key_value *kv1, struct key_value *kv2, size_t offset) +monthcoll(struct key_value *kv1, struct key_value *kv2, size_t offset __unused) { int val1, val2; bool key1_read, key2_read; @@ -1264,8 +1259,6 @@ val1 = val2 = 0; key1_read = key2_read = false; - UNUSED_ARG(offset); - if (debug_sort) { bwsprintf(stdout, kv1->k, "; k1=<", ">"); bwsprintf(stdout, kv2->k, "; k2=<", ">"); Index: sort.h =================================================================== --- sort.h (revision 236759) +++ sort.h (working copy) @@ -41,8 +41,6 @@ #define VERSION "2.3-FreeBSD" -#define UNUSED_ARG(A) do { (void)(A); } while(0) - #ifdef WITHOUT_NLS #define getstr(n) nlsstr[n] #else Gabor