From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S263573AbTDWTtC (ORCPT ); Wed, 23 Apr 2003 15:49:02 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S263576AbTDWTtC (ORCPT ); Wed, 23 Apr 2003 15:49:02 -0400 Received: from covert.brown-ring.iadfw.net ([209.196.123.142]:44306 "EHLO covert.brown-ring.iadfw.net") by vger.kernel.org with ESMTP id S263573AbTDWTs7 (ORCPT ); Wed, 23 Apr 2003 15:48:59 -0400 Date: Wed, 23 Apr 2003 15:01:04 -0500 From: Art Haas To: linux-kernel@vger.kernel.org Subject: [PATCH] Replace const to remove warnings Message-ID: <20030423200104.GA9189@debian> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.4i Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Hi. I'd posted a patch a day or two ago which removed some __const__ declarations that GCC said were not needed. A reply to the posting suggested that using __attribute__((const)) was the correct approach. The attached patch adds the attribute. Here's the initial mail for reference ... http://www.ussg.iu.edu/hypermail/linux/kernel/0304.2/1440.html I've built a kernel with this patch and it's running now - 2.5.68-bk? from April 23 Art Haas ===== include/asm-i386/byteorder.h 1.2 vs edited ===== --- 1.2/include/asm-i386/byteorder.h Fri Oct 11 12:15:35 2002 +++ edited/include/asm-i386/byteorder.h Wed Apr 23 10:28:43 2003 @@ -10,7 +10,7 @@ #include #endif -static __inline__ __const__ __u32 ___arch__swab32(__u32 x) +static __inline__ __attribute__((const)) __u32 ___arch__swab32(__u32 x) { #ifdef CONFIG_X86_BSWAP __asm__("bswap %0" : "=r" (x) : "0" (x)); @@ -26,7 +26,7 @@ /* gcc should generate this for open coded C now too. May be worth switching to it because inline assembly cannot be scheduled. -AK */ -static __inline__ __const__ __u16 ___arch__swab16(__u16 x) +static __inline__ __attribute__((const)) __u16 ___arch__swab16(__u16 x) { __asm__("xchgb %b0,%h0" /* swap bytes */ : "=q" (x) ===== include/linux/byteorder/swab.h 1.2 vs edited ===== --- 1.2/include/linux/byteorder/swab.h Tue Feb 5 01:43:00 2002 +++ edited/include/linux/byteorder/swab.h Wed Apr 23 10:28:01 2003 @@ -128,7 +128,7 @@ #endif /* OPTIMIZE */ -static __inline__ __const__ __u16 __fswab16(__u16 x) +static __inline__ __attribute__((const)) __u16 __fswab16(__u16 x) { return __arch__swab16(x); } @@ -141,7 +141,7 @@ __arch__swab16s(addr); } -static __inline__ __const__ __u32 __fswab32(__u32 x) +static __inline__ __attribute__((const)) __u32 __fswab32(__u32 x) { return __arch__swab32(x); } @@ -155,7 +155,7 @@ } #ifdef __BYTEORDER_HAS_U64__ -static __inline__ __const__ __u64 __fswab64(__u64 x) +static __inline__ __attribute__((const)) __u64 __fswab64(__u64 x) { # ifdef __SWAB_64_THRU_32__ __u32 h = x >> 32; -- To announce that there must be no criticism of the President, or that we are to stand by the President, right or wrong, is not only unpatriotic and servile, but is morally treasonable to the American public. -- Theodore Roosevelt, Kansas City Star, 1918