From patchwork Tue Aug 9 02:16:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikunj A Dadhania X-Patchwork-Id: 657060 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3s7dGY3TSqz9t0H for ; Tue, 9 Aug 2016 12:17:41 +1000 (AEST) Received: from ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3s7dGY1qmGzDqf6 for ; Tue, 9 Aug 2016 12:17:41 +1000 (AEST) X-Original-To: slof@lists.ozlabs.org Delivered-To: slof@lists.ozlabs.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3s7dFC3KNHzDqdh for ; Tue, 9 Aug 2016 12:16:31 +1000 (AEST) Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u792E7Pi080107 for ; Mon, 8 Aug 2016 22:16:29 -0400 Received: from e23smtp05.au.ibm.com (e23smtp05.au.ibm.com [202.81.31.147]) by mx0a-001b2d01.pphosted.com with ESMTP id 24ncdc8nsq-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 08 Aug 2016 22:16:29 -0400 Received: from localhost by e23smtp05.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 9 Aug 2016 12:16:26 +1000 Received: from d23dlp02.au.ibm.com (202.81.31.213) by e23smtp05.au.ibm.com (202.81.31.211) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 9 Aug 2016 12:16:20 +1000 X-IBM-Helo: d23dlp02.au.ibm.com X-IBM-MailFrom: nikunj@linux.vnet.ibm.com X-IBM-RcptTo: slof@lists.ozlabs.org Received: from d23relay09.au.ibm.com (d23relay09.au.ibm.com [9.185.63.181]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id 684492BB0059 for ; Tue, 9 Aug 2016 12:16:20 +1000 (EST) Received: from d23av05.au.ibm.com (d23av05.au.ibm.com [9.190.234.119]) by d23relay09.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u792GKUu7929912 for ; Tue, 9 Aug 2016 12:16:20 +1000 Received: from d23av05.au.ibm.com (localhost [127.0.0.1]) by d23av05.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u792GJrk026827 for ; Tue, 9 Aug 2016 12:16:20 +1000 Received: from abhimanyu.vnet.linux.ibm.com ([9.79.236.116]) by d23av05.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u792GDAc026525 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 9 Aug 2016 12:16:17 +1000 From: Nikunj A Dadhania To: Segher Boessenkool In-Reply-To: <20160808092258.GJ26795@gate.crashing.org> References: <1470256668-21374-1-git-send-email-thuth@redhat.com> <20160805084818.GD4354@redhat.com> <20160808013006.GF26795@gate.crashing.org> <051388ab-65d0-b3f2-60bf-bf361aedac2f@redhat.com> <20160808083106.GG26795@gate.crashing.org> <87popjwrig.fsf@abhimanyu.i-did-not-set--mail-host-address--so-tickle-me> <20160808092258.GJ26795@gate.crashing.org> User-Agent: Notmuch/0.21 (https://notmuchmail.org) Emacs/25.0.94.1 (x86_64-redhat-linux-gnu) Date: Tue, 09 Aug 2016 07:46:13 +0530 MIME-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16080902-0016-0000-0000-000001BC0EE3 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16080902-0017-0000-0000-0000052C33C8 Message-Id: <87k2fqwutu.fsf@abhimanyu.i-did-not-set--mail-host-address--so-tickle-me> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-08-09_01:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1604210000 definitions=main-1608090024 Subject: Re: [SLOF] [PATCH] Fix remaining compiler warnings in sloffs.c X-BeenThere: slof@lists.ozlabs.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "Patches for https://github.com/aik/SLOF" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , Adrian Reber , slof@lists.ozlabs.org Errors-To: slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "SLOF" Segher Boessenkool writes: > On Mon, Aug 08, 2016 at 02:45:35PM +0530, Nikunj A Dadhania wrote: >> >>> In the end, we just might want to add -fno-strict-aliasing to the >> >>> HOSTCFLAGS, just like we already did it in make.rules for the normal >> >>> CFLAGS, and call it a day. >> >> >> >> Or you could fix the problems. SLOF used to work with -fstrict-aliasing, >> >> and it was a nice performance win. >> > >> > That's a question for Nikunj who committed that change a couple of years >> > ago ... >> > (see http://git.qemu.org/?p=SLOF.git;a=commitdiff;h=7eca6a5e56f468) >> >> I remember that we had a discussion on this and BenH had suggested that >> we cannot re-audit all the code for correctness with strict-aliasing. So >> disable it. > > That's what -Wstrict-aliasing is for (needs -fstrict-aliasing active as > well, to work). > > Rewriting the code to make it better can be quite a bit of work, of > course. But you could e.g. only use -fno-strict-aliasing on those files > where -Wstrict-aliasing warns. I think this is what is needed. I have to test this well, as I am not exactly sure what was the way we were hitting this. diff --git a/clients/net-snk/app/netlib/ipv4.c b/clients/net-snk/app/netlib/ipv4.c index 3a1a789..157d71c 100644 --- a/clients/net-snk/app/netlib/ipv4.c +++ b/clients/net-snk/app/netlib/ipv4.c @@ -547,7 +547,7 @@ static void fill_udp_checksum(struct iphdr *ipv4_hdr) unsigned i; unsigned long checksum = 0; struct iphdr ip_hdr; - char *ptr; + uint16_t *ptr; udp_hdr_t *udp_hdr; udp_hdr = (udp_hdr_t *) (ipv4_hdr + 1); @@ -559,13 +559,13 @@ static void fill_udp_checksum(struct iphdr *ipv4_hdr) ip_hdr.ip_len = udp_hdr->uh_ulen; ip_hdr.ip_p = ipv4_hdr->ip_p; - ptr = (char*) udp_hdr; - for (i = 0; i < udp_hdr->uh_ulen; i+=2) - checksum += *((uint16_t*) &ptr[i]); + ptr = (uint16_t*) udp_hdr; + for (i = 0; i < udp_hdr->uh_ulen; i++) + checksum += ptr[i]; - ptr = (char*) &ip_hdr; - for (i = 0; i < sizeof(struct iphdr); i+=2) - checksum += *((uint16_t*) &ptr[i]); + ptr = (uint16_t*) &ip_hdr; + for (i = 0; i < sizeof(struct iphdr); i++) + checksum += ptr[i]; checksum = (checksum >> 16) + (checksum & 0xffff); checksum += (checksum >> 16); diff --git a/make.rules b/make.rules index cbc6353..e78f78d 100644 --- a/make.rules +++ b/make.rules @@ -73,7 +73,7 @@ RANLIB ?= $(CROSS)ranlib CPP ?= $(CROSS)cpp WARNFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -CFLAGS ?= -g -O2 -fno-builtin -ffreestanding -nostdinc -msoft-float -fno-strict-aliasing \ +CFLAGS ?= -g -O2 -fno-builtin -ffreestanding -nostdinc -msoft-float \ -mno-altivec -mabi=no-altivec -fno-stack-protector $(WARNFLAGS) export CC AS LD CLEAN OBJCOPY OBJDUMP STRIP AR RANLIB CFLAGS diff --git a/slof/Makefile.inc b/slof/Makefile.inc index 8ad3337..93b6fda 100644 --- a/slof/Makefile.inc +++ b/slof/Makefile.inc @@ -29,7 +29,7 @@ INCLBRDDIR ?= $(TOPBRDDIR)/include CPPFLAGS += -I. -I$(INCLCMNDIR) -I$(INCLBRDDIR) -I$(INCLCMNDIR)/$(CPUARCH) CFLAGS = -DTARG=$(TARG) -static -Wall -W -std=gnu99 \ -O2 -fomit-frame-pointer -msoft-float $(FLAG) $(CPUARCHDEF) \ - -fno-stack-protector -fno-strict-aliasing + -fno-stack-protector ASFLAGS = -Wa,-mpower4 -Wa,-mregnames $(FLAG) $(CPUARCHDEF) LDFLAGS += -static -nostdlib -Wl,-q,-n