Skip to contentSkip to conversation

checkpatch-warn-on-uses-of-__constant_foo-functions.patch removed from -mm tree

merged [email protected] 1 participant 1 message Apr 4, 2014 Checkpatch

lore
Share & tools
lore
#0 lore raw

Subject: [merged] checkpatch-warn-on-uses-of-__constant_foo-functions.patch removed from -mm tree
To: [email protected],[email protected],[email protected],[email protected]
From: [email protected]
Date: Fri, 04 Apr 2014 12:33:58 -0700

The patch titled
Subject: checkpatch: warn on uses of __constant_<foo> functions
has been removed from the -mm tree. Its filename was
checkpatch-warn-on-uses-of-__constant_foo-functions.patch

This patch was dropped because it was merged into mainline or a subsystem tree

------------------------------------------------------
From: Joe Perches <[email protected]>
Subject: checkpatch: warn on uses of __constant_<foo> functions

Emit a warning when using any of these __constant_<foo> forms:

	__constant_cpu_to_be[x]
	__constant_cpu_to_le[x]
	__constant_be[x]_to_cpu
	__constant_le[x]_to_cpu
	__constant_htons
	__constant_ntohs

Using any of these outside of include/uapi/ isn't preferred as using the function without __constant_ is identical when the argument is a constant.

Cc Andy Whitcroft <[email protected]>
Cc Simon Wunderlich <[email protected]>

---

 scripts/checkpatch.pl |   13 +++++++++++++
 1 file changed, 13 insertions(+)
scripts/checkpatch.pl renamed from scripts/checkpatch.pl~checkpatch-warn-on-uses-of-__constant_foo-functions +13 -0
diff -puN scripts/checkpatch.pl~checkpatch-warn-on-uses-of-__constant_foo-functions scripts/checkpatch.pl
@@ -3931,6 +3931,19 @@ sub process {
 			}
 		}
 
+# don't use __constant_<foo> functions outside of include/uapi/
+		if ($realfile !~ m@^include/uapi/@ &&
+		    $line =~ /(__constant_(?:htons|ntohs|[bl]e(?:16|32|64)_to_cpu|cpu_to_[bl]e(?:16|32|64)))\s*\(/) {
+			my $constant_func = $1;
+			my $func = $constant_func;
+			$func =~ s/^__constant_//;
+			if (WARN("CONSTANT_CONVERSION",
+				 "$constant_func should be $func\n" . $herecurr) &&
+			    $fix) {
+				$fixed[$linenr - 1] =~ s/\b$constant_func\b/$func/g;
+			}
+		}
+
 # prefer usleep_range over udelay
 		if ($line =~ /\budelay\s*\(\s*(\d+)\s*\)/) {
 			my $delay = $1;

_

Patches currently in -mm which might be from [email protected] are

origin.patch
ntfs-logging-clean-up.patch
mm-utilc-add-kstrimdup.patch checkpatch-always-warn-on-missing-blank-line-after-variable-declaration-block.patch checkpatch-reduce-false-positives-for-missing-blank-line-after-declarations-test.patch checkpatch-reduce-false-positives-for-missing-blank-line-after-declarations-test-fix.patch ncpfs-add-pr_fmt-and-convert-printks-to-pr_level.patch ncpfs-convert-dprintk-ddprintk-to-ncp_dbg.patch ncpfs-convert-dprintk-ddprintk-to-ncp_dbg-fix.patch ncpfs-convert-dprintk-ddprintk-to-ncp_dbg-fix-fix.patch ncpfs-convert-pprintk-to-ncp_vdbg.patch ncpfs-remove-now-unused-printk-macro.patch ncpfs-inode-fix-mismatch-printk-formats-and-arguments.patch linux-next.patch