Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp1602254ybm; Sat, 30 May 2020 14:24:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxdZKCiNw1ICX7uEeW1YuoaT1u6irwEzHnvSBUGFMLuMRhItNEIm46G7sE3eyhWUAllhhTN X-Received: by 2002:a17:906:2b04:: with SMTP id a4mr13602399ejg.98.1590873842103; Sat, 30 May 2020 14:24:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590873842; cv=none; d=google.com; s=arc-20160816; b=WSE/uSbDbk4mMeBU9Md8re3FOb5JHCsWVdNumF5xZSHQMbjrlKBgiP5hs+awh7N4RM f+XoHRdgK0CeHj3UjMaUsynzeAFQBSx53rN45hssTDEWSXKPOJB8bstTwTAuqzL6TJV+ OC8vg2QwYkVbSMllg3cH3beArWtsvd370iNnLHcLaNAe+SOr+P9bDPyrZlNw+UqenYxz hG2boIzWJeYHxlseP2QKjbaAxwVgZeGqLuQ1VZA2N1twwuL8r8QR7PGUXtDlef7QadCd e9wv7rFDmpgOoSPKuHbTGfdk4B2w3RqGWKlFjqSvQULTjOzjZVmLST4s5GmuIiQw0Uhn EBRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=wt7DeyDhX+RpnOwE14bZ128gk/jokCi5wj4+Egs8otU=; b=D7bDaaOQ1zjLmbaTYJvByNhGLOHqXz9miWXVPC2qXonZiFy8AOUxtHRaQTTTvynF74 Q80WNVzYMDd34A6l0BCubTupluu8zzMMadvtkWm+BN0lB3P/0urCi1Kv3O4k7wxKrWsh IjVPV8ScOgXyffVVZBxa4pIhm8RW1sEkcOPD5uvlDk3t7R23a3jX7tVhP0DeJjPYL4ur iV3ciAcoROG5A/LnJtvXcckKbqDIrk9oOGnTR8KSXoFGdNho4KJdDgsEdecJNyvDUEDY CCFUyWLyphExjTce/9jMS80jwYyJUm88Jtba3bl9maafTA6xRbt+ZvNczLCpKs/PAtJd 3hqw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ds22si2470913ejc.470.2020.05.30.14.23.38; Sat, 30 May 2020 14:24:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729329AbgE3VVt (ORCPT + 99 others); Sat, 30 May 2020 17:21:49 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:34615 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728999AbgE3VVt (ORCPT ); Sat, 30 May 2020 17:21:49 -0400 Received: by mail-lj1-f195.google.com with SMTP id b6so3549243ljj.1 for ; Sat, 30 May 2020 14:21:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=wt7DeyDhX+RpnOwE14bZ128gk/jokCi5wj4+Egs8otU=; b=CteddQB0Md+5T3Zwav1qNZOCgj3E7v2e647nB8PQ9pXuzVkJfJrvTcpYFNEJbdsbY+ zJGE0Gngi6VPUlMj54nYS9vJ/rdTjEb1ZKROCAKVy7fSZuqpUPa1QxWcgghXsTcgRfF3 ln64ckS88dLUywgyRAU0WylxlreBFpw51zlhuIAwvNyenIecvkj64+p72C2bKDePkZRT wpdJFLHPNNjiYCq02FijizX3pjcUkDvdHCUuBqt2k7xL48BpmkqpZWRopcjFpOlWBK52 WjFAPM3/U1z9k4RGCuzGkcibwAV5R/7KiBU4UcCuKYhOL/f5GDL1eMK4HJPniS10NAAx 4+sg== X-Gm-Message-State: AOAM531dLfkasB8B78cbLknDZ5R/gNSQrGxazPsOlchD2v1R/m/o/oco y0ZWhKDNPGA7kFrqegdHjWg= X-Received: by 2002:a2e:b52d:: with SMTP id z13mr1335086ljm.299.1590873707038; Sat, 30 May 2020 14:21:47 -0700 (PDT) Received: from localhost.localdomain ([213.87.147.196]) by smtp.googlemail.com with ESMTPSA id u15sm3262161lfg.92.2020.05.30.14.21.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 May 2020 14:21:46 -0700 (PDT) From: Denis Efremov To: Joe Perches , Andy Whitcroft Cc: Denis Efremov , linux-kernel@vger.kernel.org Subject: [RFC PATCH] checkpatch: check for trivial sizeofs Date: Sun, 31 May 2020 00:21:29 +0300 Message-Id: <20200530212129.7498-1-efremov@linux.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org sizeof(char) and its variations in most cases doesn't make code more clear. It only makes code wordy. Signed-off-by: Denis Efremov --- scripts/checkpatch.pl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index eac40f0abd56..9dd338b125d2 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -6045,6 +6045,13 @@ sub process { } } +# check for trivial sizeof(char) == 1 + if ($line =~ /\bsizeof\s*\(\s*((?:(?:un)?signed\s+)?char|(?:__)?u8|u?int8_t|[us]?byte(?:_t)?)\s*\)/) { + my $byte = $1; + CHK("SIZEOF_TRIVIAL", + "redundant sizeof($byte) == 1 \n" . $herecurr); + } + # check for struct spinlock declarations if ($line =~ /^.\s*\bstruct\s+spinlock\s+\w+\s*;/) { WARN("USE_SPINLOCK_T", -- 2.26.2