From ee1fb07c8ebd84207a09122d876bfd3f475c6ff6 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Sun, 29 Oct 2017 21:29:04 +1030 Subject: [PATCH] update-mocks: fix stubs generation for fatal(). We're going to need this, and the PRINTF_FMT(1,2) in front of it caused mockup.sh to miss the declaration. We also eliminate the obviously-unused fallback case (which referred to daemon/*.h). Signed-off-by: Rusty Russell --- tools/mockup.sh | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/tools/mockup.sh b/tools/mockup.sh index 1fd293ab432a..f8a0fc95ebb2 100755 --- a/tools/mockup.sh +++ b/tools/mockup.sh @@ -15,17 +15,12 @@ if [ $# -eq 0 ]; then fi for SYMBOL; do - WHERE=$(grep -nH "^[a-z0-9_ ]* [*]*$SYMBOL(" */*.h ) + WHERE=$(grep -nH "^[a-zA-Z0-9_ (),]* [*]*$SYMBOL(" */*.h ) if [ x"$WHERE" != x ]; then STUB='\n{ fprintf(stderr, "'$SYMBOL' called!\\n"); abort(); }' else - WHERE=$(grep -nH "^extern \(const \)\?struct [a-zA-Z0-9_]* $SYMBOL;$" daemon/*.h) - if [ x"$WHERE" != x ]; then - STUB=';' - else - echo "/* Could not find declaration for $SYMBOL */" - continue - fi + echo "/* Could not find declaration for $SYMBOL */" + continue fi echo "/* Generated stub for $SYMBOL */" @@ -35,5 +30,5 @@ for SYMBOL; do END=$(tail -n +$LINE < $FILE | grep -n ';$'); NUM=${END%%:*} - tail -n +$LINE < $FILE | head -n $NUM | sed 's/^extern *//' | sed 's/PRINTF_FMT([^)]*)//' | sed 's/,/ UNNEEDED,/g' | sed 's/\([a-z0-9A-Z*_]* [a-z0-9A-Z*_]*\));/\1 UNNEEDED);/' | sed "s/;\$/$STUB/" | sed 's/\s*$//' + tail -n +$LINE < $FILE | head -n $NUM | sed 's/^extern *//' | sed 's/PRINTF_FMT([^)]*)//' | sed 's/NORETURN//g' | sed 's/,/ UNNEEDED,/g' | sed 's/\([a-z0-9A-Z*_]* [a-z0-9A-Z*_]*\));/\1 UNNEEDED);/' | sed "s/;\$/$STUB/" | sed 's/\s*$//' done