Skip to content

Commit a8cf816

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 096626a commit a8cf816

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

regen/embed.pl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,25 @@ sub generate_proto_h {
274274
$arg =~ s/\s+$//;
275275
$arg =~ s/\s{2,}/ /g;
276276

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

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

0 commit comments

Comments
 (0)