Skip to content

Commit d2af241

Browse files
committed
scripts: checkpatch: diagnose uses of %pA in the C side
The `%pA` format specifier is only intended to be used from Rust. `checkpatch.pl` already gives a warning for invalid specificers: WARNING: Invalid vsprintf pointer extension '%pA' With this change, we introduce an error message with further explanation: ERROR: '%pA' is only intended to be used from Rust code Suggested-by: Kees Cook <[email protected]> Co-developed-by: Alex Gaynor <[email protected]> Signed-off-by: Alex Gaynor <[email protected]> Co-developed-by: Wedson Almeida Filho <[email protected]> Signed-off-by: Wedson Almeida Filho <[email protected]> Signed-off-by: Miguel Ojeda <[email protected]>
1 parent e00531c commit d2af241

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

scripts/checkpatch.pl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6784,6 +6784,10 @@ sub process {
67846784
my $stat_real = get_stat_real($linenr, $lc);
67856785
my $ext_type = "Invalid";
67866786
my $use = "";
6787+
if ($bad_specifier =~ /pA/) {
6788+
ERROR("VSPRINTF_RUST",
6789+
"'\%pA' is only intended to be used from Rust code\n" . "$here\n$stat_real\n");
6790+
}
67876791
if ($bad_specifier =~ /p[Ff]/) {
67886792
$use = " - use %pS instead";
67896793
$use =~ s/pS/ps/ if ($bad_specifier =~ /pf/);

0 commit comments

Comments
 (0)