xfs/122: escape %zu in printf with %% not \\%
PATCH 1/1 xfs/122: escape %zu in printf with %% not \\%
The standard way to escape % in a printf is with %%; although \\%zu seems to have worked in awk until recently, an upgrade on Fedora 36 has started failing:
awk: cmd. line:1: (FILENAME=- FNR=1) fatal: not enough arguments to satisfy format string
'printf("sizeof(%s) = \%zu\n", sizeof(%s));
'
^ ran out for this oneSwitching the escape to "%%" fixes this for me, and also works on my very old RHEL7 mcahine.
--- tests/xfs/122 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tests/xfs/122 +2 -2
@@ -186,7 +186,7 @@ egrep '(} *xfs_.*_t|^struct xfs_[a-z0-9_]*$)' |\ egrep -v -f $tmp.ignore |\ sed -e 's/^.*}[[:space:]]*//g' -e 's/;.*$//g' -e 's/_t, /_t\n/g' |\ sort | uniq |\ -awk '{printf("printf(\"sizeof(%s) = \\%zu\\n\", sizeof(%s));\n", $0, $0);}' |\ +awk '{printf("printf(\"sizeof(%s) = %%zu\\n\", sizeof(%s));\n", $0, $0);}' |\ cat >> $cprog #
@@ -199,7 +199,7 @@ awk ' /typedef struct xfs_sb/ { structon = 1; next } structon && $2 ~ /^sb_/ { sub(/[;,]/,"",$2) sub(/XFSLABEL_MAX/,"12",$2) - printf("printf(\"offsetof(xfs_sb_t, %s) = \\%zu\\n\", offsetof(xfs_sb_t, %s));", $2, $2); next} + printf("printf(\"offsetof(xfs_sb_t, %s) = %%zu\\n\", offsetof(xfs_sb_t, %s));", $2, $2); next} structon && /}/ { structon = 0; next} '>>$cprog
Signature · 1 line
1.8.3.1
Quoted 5 lines · Eric Sandeen
The standard way to escape % in a printf is with %%; although \\%zu seems to have worked in awk until recently, an upgrade on Fedora 36 has started failing:
awk: cmd. line:1: (FILENAME=- FNR=1) fatal: not enough arguments to satisfy format string
Quoted 8 lines
'printf("sizeof(%s) = \%zu\n", sizeof(%s)); ' ^ ran out for this oneSwitching the escape to "%%" fixes this for me, and also works on my very old RHEL7 mcahine.
Signed-off-by Eric Sandeen <[email protected]>---
Make sense, thanks for fixing this.
Quoted 28 lines
tests/xfs/122 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)tests/xfs/122 +2
-2@@ -186,7 +186,7 @@ egrep '(} *xfs_.*_t|^struct xfs_[a-z0-9_]*$)' |\ egrep -v -f $tmp.ignore |\ sed -e 's/^.*}[[:space:]]*//g' -e 's/;.*$//g' -e 's/_t, /_t\n/g' |\ sort | uniq |\ -awk '{printf("printf(\"sizeof(%s) = \\%zu\\n\", sizeof(%s));\n", $0, $0);}' |\ +awk '{printf("printf(\"sizeof(%s) = %%zu\\n\", sizeof(%s));\n", $0, $0);}' |\ cat >> $cprog #@@ -199,7 +199,7 @@ awk ' /typedef struct xfs_sb/ { structon = 1; next } structon && $2 ~ /^sb_/ { sub(/[;,]/,"",$2) sub(/XFSLABEL_MAX/,"12",$2) - printf("printf(\"offsetof(xfs_sb_t, %s) = \\%zu\\n\", offsetof(xfs_sb_t, %s));", $2, $2); next} + printf("printf(\"offsetof(xfs_sb_t, %s) = %%zu\\n\", offsetof(xfs_sb_t, %s));", $2, $2); next} structon && /}/ { structon = 0; next} '>>$cprogSignature · 1 line
1.8.3.1