Skip to content

Commit ca3b9c2

Browse files
committed
regen/embed.pl: Improve error checking
This commit verifies that only one of the mutually exclusive argument modifiers, like NN, is present, and that NZ isn't used for a pointer argument.
1 parent f9eae31 commit ca3b9c2

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

regen/embed.pl

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -256,14 +256,6 @@ sub generate_proto_h {
256256
unless $has_mflag;
257257
}
258258
else {
259-
if ( $args_assert_line
260-
&& $arg =~ /\*/
261-
&& $arg !~ /\b(NN|NULLOK)\b/ )
262-
{
263-
warn "$func: $arg needs NN or NULLOK\n";
264-
++$unflagged_pointers;
265-
}
266-
267259
my $nn = ( $arg =~ s/\bNN\b// );
268260
my $nz = ( $arg =~ s/\bNZ\b// );
269261
my $nullok = ( $arg =~ s/\bNULLOK\b// );
@@ -274,6 +266,25 @@ sub generate_proto_h {
274266
$arg =~ s/\s+$//;
275267
$arg =~ s/\s{2,}/ /g;
276268

269+
die_at_end ":$func: $arg Use only one of NN, NULLOK, and NZ"
270+
if 0 + $nn + $nz + $nullok > 1;
271+
272+
push( @nonnull, $n ) if $nn;
273+
274+
# A non-pointer shouldn't have a pointer-related modifier.
275+
# But typedefs may be pointers without our knowing it, so
276+
# we can't check for non-pointer issues. We can only
277+
# check for the case where the argument is definitely a
278+
# pointer.
279+
if ($args_assert_line && $arg =~ /\*/) {
280+
if ($nn + $nullok == 0) {
281+
warn "$func: $arg needs NN or NULLOK\n";
282+
++$unflagged_pointers;
283+
}
284+
285+
warn "$func: $arg should not have NZ\n" if $nz;
286+
}
287+
277288
push( @nonnull, $n ) if $nn;
278289

279290
# Make sure each arg has at least a type and a var name.

0 commit comments

Comments
 (0)