From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753142AbcF1Ktx (ORCPT ); Tue, 28 Jun 2016 06:49:53 -0400 Received: from s3.sipsolutions.net ([5.9.151.49]:44913 "EHLO sipsolutions.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753048AbcF1Ktu (ORCPT ); Tue, 28 Jun 2016 06:49:50 -0400 Message-ID: <1467110982.2493.10.camel@sipsolutions.net> Subject: Re: [PATCH] nl80211: improve nl80211_parse_mesh_config type checking From: Johannes Berg To: Arnd Bergmann Cc: "David S. Miller" , Jouni Malinen , Emmanuel Grumbach , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Date: Tue, 28 Jun 2016 12:49:42 +0200 In-Reply-To: <20160615203012.3544326-1-arnd@arndb.de> References: <20160615203012.3544326-1-arnd@arndb.de> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.20.2-2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2016-06-15 at 22:29 +0200, Arnd Bergmann wrote: > When building a kernel with W=1, the nl80211.c file causes a number > of > warnings, all about the same problem: > > net/wireless/nl80211.c: In function 'nl80211_parse_mesh_config': > net/wireless/nl80211.c:5287:103: error: comparison is always false > due to limited range of data type [-Werror=type-limits] > net/wireless/nl80211.c:5290:96: error: comparison is always false due > to limited range of data type [-Werror=type-limits] > net/wireless/nl80211.c:5293:124: error: comparison is always false > due to limited range of data type [-Werror=type-limits] > net/wireless/nl80211.c:5295:148: error: comparison is always false > due to limited range of data type [-Werror=type-limits] > net/wireless/nl80211.c:5298:106: error: comparison is always false > due to limited range of data type [-Werror=type-limits] > net/wireless/nl80211.c:5305:116: error: comparison is always false > due to limited range of data type [-Werror=type-limits] > > The problem is that gcc does not notice that the check is generate > by a macro, so it complains about comparing an unsigned type against > 0. > > I've tried to come up with a way to rephrase that code in a way that > avoids the warnings and otherwise improves the code as well. > > This uses a set of new helper functions that perform the range > checking, > and should provide slightly better type safety than the older patch, > at the expense of adding 44 lines to the code. Binary code size is > basically unchanged though (20 bytes added to 126561 bytes .text). > Applied. johannes