From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2D459524F for ; Sat, 28 Dec 2024 13:05:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735391123; cv=none; b=GXOjBIK3U9EX+c8U357ow06Akpwc/gazqxNjazOLAaDw7/hplTMwwsgs4bWzAPjOz74pnZmh4VlwgZ2E4/uJ+RnLnVoH4Gs/3BehiL3R1lIF8mtn8goAYd9G+rGHCvtM2SyDW3T8ZnNBHKyRpjY7TsQI+U3S9tFvngk3b6HCT40= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735391123; c=relaxed/simple; bh=tLI00AdoqUX3ManMczGAXIItQYoANNYhRX/hnbOxpIw=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=EWg88XpsXDanMMJq8y/ym0E42cU5EKUYy/FZ3bPsa5GytdeFygRsImj4mrSNmSE36NfrmBg+w0f3Oz1GxcCepKKmijfUcvO++pn5Dvy3uktTci4Ah7sgIUwbDaZ1yLBihp/iILg5cLaNRmFng4k3N5XKE1zlp7Q8GEteef2G4w0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=FTMFXkby; arc=none smtp.client-ip=209.85.221.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FTMFXkby" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-3862a921123so5340540f8f.3 for ; Sat, 28 Dec 2024 05:05:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735391117; x=1735995917; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=ROvqpR6bRBvuV+u1dc5rm4nTWqVWC2mi+p9zbxlzMAQ=; b=FTMFXkbyMG9k2XZxRTAKDG/nrhiKmeZxD/QPHLRfBcIC0HIHU87sZmD9VjR9yRucUJ UICkuDKcFwyoGbQhAvBpomCNvDX88vXJCNh0LFbEqWwa1bO8c2I7DspApNo+7bJUBDDm sOM5CqwmG3TOm7C6qTmn3mDqql+jaPEU/5Z9WdQ+luhHooJ+sXh6S8EhydUqTWxl7sPk EEJQApMNHXYp3QOlKb9Rdctd7gqilc5leo29lBiE8PNpTj7RKQ4n9opmJHw2lOAGcCk/ +6IJC62ow81N8Gezuzppx/VXDY3cvFxl7Xh3V+sfx9Obmaykk3O0+0jfKFIn2EWt7xI5 vRWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735391117; x=1735995917; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ROvqpR6bRBvuV+u1dc5rm4nTWqVWC2mi+p9zbxlzMAQ=; b=M8v2Zc59Yn/pmTGKAq4NpjBHQSLX+gVFCiCJuLYH2ubdbg2ZZhOaX5hp1X2kDxXblm 0/SxBAYBqnBxKoQ0oqLyKM+4+l647iCUy7gl2uIAn5DujR6nSoe9vnyBonL6ZO3aDvU6 5CEuICRA/mQJzHQU5jwZpwm6esPSwUVhFCwV+Ywp+5e7uJmRNoOXnhB1Zp4gP1lbbQYw UWFEpBbJA97y2bcwyVIBKSk7jsv2dJcmLDCpLXt0w3gKjb5kf90dk2hZHKhLFHjTIcDM R+1JPsAzNDAhPkBGMnLRTTNTjUsk91rq6jMqbamx3UFozUBK9HG2IIlkvNav9AQOkNnb VxkA== X-Forwarded-Encrypted: i=1; AJvYcCVyHTtoJ8Pjne6W0y1cvpd2YGQBdzPmLlKmNAs3Kp/4MnxYqbIoRN3NtwriBst7cs92m8fZZF9OyZicJpI=@vger.kernel.org X-Gm-Message-State: AOJu0YyFv9QuVDj2IyBCwQx3CPoIrwpsiVKztwcj3GhxtRudl+rbzyOW kNnqlKjZMIbw51m0p31MwVwClX+fcEqZ3hMb6/b+NNGGUUEhbluC X-Gm-Gg: ASbGncuvwR7SSirEK+koVnv9g/uaL6l0qzigdKA08WG1WDgkOvYMHvNTQY30MFZRFr3 hOyrms+qA7eyzjucdKDPNPryBEBmYlUbVEcB5ALEFx2h/aD6oK+csyooioZxdwoj9sMFmQ+/l4L Xo0oTcL+ZR96ij6qz6ghc4PS4ab8QBFMKFOSOOT1Gk+7JJUe/mSNxML/F0Q+gzSNl4wjcARMg5M s4uTIYzsG6QCF4NlghlVZCrNuza316MpURVlmU6N7Y9i7bYp7IRHJBcA+I/TFjPl0ACcYLuGZKG Q2O4vUf6IIM98MH+qOTpifo= X-Google-Smtp-Source: AGHT+IF02h27GIavoHO6IxGF3wymaG8RDR3o1DZKasrgYTqwinNNbojeBvaQ66pRgz9pMtW1B2w6/g== X-Received: by 2002:a5d:64c8:0:b0:385:ec8d:8ca9 with SMTP id ffacd0b85a97d-38a223f5c0dmr23111977f8f.42.1735391117288; Sat, 28 Dec 2024 05:05:17 -0800 (PST) Received: from dsl-u17-10 (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-436611ea423sm300398355e9.2.2024.12.28.05.05.15 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 28 Dec 2024 05:05:16 -0800 (PST) Date: Sat, 28 Dec 2024 13:05:15 +0000 From: David Laight To: kernel test robot Cc: Vadim Pasternak , oe-kbuild-all@lists.linux.dev, linux-kernel@vger.kernel.org, Andy Shevchenko , yury.norov@gmail.com Subject: Re: drivers/platform/mellanox/mlxreg-hotplug.c:87:61: warning: '%d' directive output may be truncated writing 1 byte into a region of size between 0 and 31 Message-ID: <20241228130313.4457f873@dsl-u17-10> In-Reply-To: <202412281022.emy8ZDNh-lkp@intel.com> References: <202412281022.emy8ZDNh-lkp@intel.com> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Sat, 28 Dec 2024 10:23:25 +0800 kernel test robot wrote: (resend with fixed email address) > Hi Vadim, > > FYI, the error/warning still remains. > > tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master > head: fd0584d220fe285dc45be43eede55df89ad6a3d9 > commit: 92d020f97966b1724cfcac93e89176d0eb3aca61 platform/mellanox: mlxreg-hotplug: Add environmental data to uevent > date: 4 years, 5 months ago > config: sparc-randconfig-001-20241212 (https://download.01.org/0day-ci/archive/20241228/202412281022.emy8ZDNh-lkp@intel.com/config) > compiler: sparc-linux-gcc (GCC) 12.4.0 > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241228/202412281022.emy8ZDNh-lkp@intel.com/reproduce) > > If you fix the issue in a separate patch/commit (i.e. not just a new version of > the same patch/commit), kindly add following tags > | Reported-by: kernel test robot > | Closes: https://lore.kernel.org/oe-kbuild-all/202412281022.emy8ZDNh-lkp@intel.com/ > > All warnings (new ones prefixed by >>): > > In file included from include/linux/bits.h:23, > from include/linux/bitops.h:5, > from drivers/platform/mellanox/mlxreg-hotplug.c:8: > drivers/platform/mellanox/mlxreg-hotplug.c: In function 'mlxreg_hotplug_attr_init': > include/linux/bits.h:26:42: warning: comparison of unsigned expression in '< 0' is always false [-Wtype-limits] > 26 | __builtin_constant_p((l) > (h)), (l) > (h), 0))) > | ^ > include/linux/build_bug.h:16:62: note: in definition of macro 'BUILD_BUG_ON_ZERO' > 16 | #define BUILD_BUG_ON_ZERO(e) ((int)(sizeof(struct { int:(-!!(e)); }))) > | ^ > include/linux/bits.h:39:10: note: in expansion of macro 'GENMASK_INPUT_CHECK' > 39 | (GENMASK_INPUT_CHECK(h, l) + __GENMASK(h, l)) This pretty much always gives a warning when -Wtype-limits is enabled. I'm sure someone said it was being removed from 'W=1' builds. But changing the defines to (say): __builtin_constant_p((hi) - (lo), __GENMASK((hi) - (lo), 0) << (lo), __GENMASK(hi, lo)) will remove the type-limits warning and give a 'negative shift' error if (lo) > (hi). ... > drivers/platform/mellanox/mlxreg-hotplug.c: In function 'mlxreg_hotplug_udev_event_send.isra': > >> drivers/platform/mellanox/mlxreg-hotplug.c:87:61: warning: '%d' directive output may be truncated writing 1 byte into a region of size between 0 and 31 [-Wformat-truncation=] > 87 | snprintf(event_str, MLXREG_CORE_LABEL_MAX_SIZE, "%s=%d", label, !!action); > | ^~ > drivers/platform/mellanox/mlxreg-hotplug.c:87:57: note: directive argument in the range [0, 1] > 87 | snprintf(event_str, MLXREG_CORE_LABEL_MAX_SIZE, "%s=%d", label, !!action); > | ^~~~~~~ > drivers/platform/mellanox/mlxreg-hotplug.c:87:9: note: 'snprintf' output between 3 and 34 bytes into a destination of size 32 > 87 | snprintf(event_str, MLXREG_CORE_LABEL_MAX_SIZE, "%s=%d", label, !!action); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ... The compiler is failing to note that ! returns 0 or 1! But maybe 'action != 0' will be ok. David