Skip to content

Commit a281942

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 265477c commit a281942

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,19 +256,30 @@ 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/\s*\bNN\b\s+// );
268260
my $nz = ( $arg =~ s/\s*\bNZ\b\s+// );
269261
my $nullok = ( $arg =~ s/\s*\bNULLOK\b\s+// );
270262
my $nocheck = ( $arg =~ s/\s*\bNOCHECK\b\s+// );
271263

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

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

0 commit comments

Comments
 (0)