From: Reimar.Doeffinger@gmx.de
To: ffmpeg-devel@ffmpeg.org
Cc: "Reimar Döffinger" <Reimar.Doeffinger@gmx.de>
Subject: [FFmpeg-devel] [PATCH] [RFC] tools/patcheck: portability fixes.
Date: Thu, 27 Jul 2023 20:15:52 +0200
Message-ID: <20230727181552.13387-1-Reimar.Doeffinger@gmx.de> (raw)
From: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
Enough to make it run on macOS.
In particular:
- fix "empty subexpression" errors caused by constructs like (smth|),
use ? instead to make them optional
- no -d option for xargs, use the more standard -0 and use tr to
replace newlines with 0.
Not sure if these cause issues somewhere else, not even completely
sure they all work, but quick testing suggests they work.
On the other hand I remember issues with '?' where I resorted to {0,1}
instead, but I do not remember details.
Ignore if fixing these seems not worth the risk.
---
tools/patcheck | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/tools/patcheck b/tools/patcheck
index fe52938f29..ee993c60fc 100755
--- a/tools/patcheck
+++ b/tools/patcheck
@@ -21,7 +21,7 @@ echo may or may not be bad. When you use it and it misses something or detects
echo something wrong, fix it and send a patch to the ffmpeg-devel mailing list.
echo License: GPL, Author: Michael Niedermayer
-ERE_PRITYP='(unsigned *|)(char|short|long|int|long *int|short *int|void|float|double|(u|)int(8|16|32|64)_t)'
+ERE_PRITYP='(unsigned *)?(char|short|long|int|long *int|short *int|void|float|double|u?int(8|16|32|64)_t)'
ERE_TYPES='(const|static|av_cold|inline| *)*('$ERE_PRITYP'|[a-zA-Z][a-zA-Z0-9_]*)[* ]{1,}[a-zA-Z][a-zA-Z0-9_]*'
ERE_FUNCS="$ERE_TYPES"' *\('
@@ -63,7 +63,7 @@ hiegrep '\+= *1 *;' 'can be simplified to ++' $*
hiegrep '-= *1 *;' 'can be simplified to --' $*
hiegrep '((!|=)= *(0|NULL)[^0-9a-z]|[^0-9a-z](0|NULL) *(!|=)=)' 'x==0 / x!=0 can be simplified to !x / x' $*
-$EGREP $OPT '^\+ *(const *|)static' $*| $EGREP --color=always '[^=]= *(0|NULL)[^0-9a-zA-Z]'> $TMP && printf '\nuseless 0 init\n'
+$EGREP $OPT '^\+ *(const *)?static' $*| $EGREP --color=always '[^=]= *(0|NULL)[^0-9a-zA-Z]'> $TMP && printf '\nuseless 0 init\n'
cat $TMP
hiegrep '# *ifdef * (HAVE|CONFIG)_' 'ifdefs that should be #if' $*
@@ -77,7 +77,7 @@ hiegrep ':\+ *'"$ERE_PRITYP"' *inline' 'non static inline or strangely ordered i
hiegrep "$ERE_FUNCS"' *\)' 'missing void' $*
hiegrep '(sprintf|strcat|strcpy)' 'Possible security issue, make sure this is safe or use snprintf/av_strl*' $*
hiegrep '/ *(2|4|8|16|32|64|128|256|512|1024|2048|4096|8192|16384|32768|65536)[^0-9]' 'divide by 2^x could use >> maybe' $*
-hiegrep '#(el|)if *(0|1)' 'useless #if' $*
+hiegrep '#(el)?if *(0|1)' 'useless #if' $*
hiegrep 'if *\( *(0|1) *\)' 'useless if()' $*
hiegrep '& *[a-zA-Z0-9_]* *\[ *0 *\]' 'useless & [0]' $*
hiegrep '(\( *[0-9] *(&&|\|\|)|(&&|\|\|) *[0-9] *\))' 'overriding condition' $*
@@ -118,22 +118,22 @@ if test -e $TMP ; then
cat $TMP
fi
-$EGREP -B2 $OPT '^(\+|) *('"$ERE_TYPES"'|# *define)' $* | $EGREP -A2 --color=always '(:|-)\+[^/]*/(\*([^*]|$)|/([^/]|$))' > $TMP && printf "\n Non doxy comments\n"
+$EGREP -B2 $OPT '^\+? *('"$ERE_TYPES"'|# *define)' $* | $EGREP -A2 --color=always '(:|-)\+[^/]*/(\*([^*]|$)|/([^/]|$))' > $TMP && printf "\n Non doxy comments\n"
cat $TMP
rm $TMP
for i in \
$($EGREP -H '^\+ *'"$ERE_TYPES" $* |\
$GREP -v '(' | $EGREP -v '\Wgoto\W' |\
- xargs -d '\n' -n 1 |\
+ tr '\n' '\0' | xargs -0 -n 1 |\
$GREP -o '[* ][* ]*[a-zA-Z][0-9a-zA-Z_]* *[,;=]' |\
sed 's/.[* ]*\([a-zA-Z][0-9a-zA-Z_]*\) *[,;=]/\1/') \
; do
echo $i | $GREP '^NULL$' && continue
- $EGREP $i' *(\+|-|\*|/|\||&|%|)=[^=]' $* >/dev/null || echo "possibly never written:"$i >> $TMP
+ $EGREP $i' *(\+|-|\*|/|\||&|%)?=[^=]' $* >/dev/null || echo "possibly never written:"$i >> $TMP
$EGREP '(=|\(|return).*'$i'(==|[^=])*$' $* >/dev/null || echo "possibly never read :"$i >> $TMP
- $EGREP -o $i' *((\+|-|\*|/|\||&|%|)=[^=]|\+\+|--) *(0x|)[0-9]*(;|)' $* |\
- $EGREP -v $i' *= *(0x|)[0-9]{1,};'>/dev/null || echo "possibly constant :"$i >> $TMP
+ $EGREP -o $i' *((\+|-|\*|/|\||&|%)?=[^=]|\+\+|--) *(0x)?[0-9]*;?' $* |\
+ $EGREP -v $i' *= *(0x)?[0-9]{1,};'>/dev/null || echo "possibly constant :"$i >> $TMP
done
if test -e $TMP ; then
printf '\npossibly unused variables\n'
@@ -151,7 +151,7 @@ cat $TMP | tr '@' '\n'
cat $* | tr '\n' '@' | $EGREP --color=always -o '\+ *if *\( *([A-Za-z0-9_]*) *[<>]=? *([A-Za-z0-9_]*) *\)[ @\\+]*(\1|\2) *= *(\1|\2) *;' >$TMP && printf "\nFFMIN/FFMAX\n"
cat $TMP | tr '@' '\n'
-cat $* | tr '\n' '@' | $EGREP --color=always -o '\+ *if *\( *([A-Za-z0-9_]*) *\)[ @\\+]*av_free(p|) *\( *(&|) *\1[^-.]' >$TMP && printf "\nav_free(NULL) is safe\n"
+cat $* | tr '\n' '@' | $EGREP --color=always -o '\+ *if *\( *([A-Za-z0-9_]*) *\)[ @\\+]*av_freep? *\( *&? *\1[^-.]' >$TMP && printf "\nav_free(NULL) is safe\n"
cat $TMP | tr '@' '\n'
cat $* | tr '\n' '@' | $EGREP --color=always -o '[^a-zA-Z0-9_]([a-zA-Z0-9_]*) *= *av_malloc *\([^)]*\)[ @;\\+]*memset *\( *\1' >$TMP && printf "\nav_mallocz()\n"
--
2.37.1 (Apple Git-137.1)
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next reply other threads:[~2023-07-27 18:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-27 18:15 Reimar.Doeffinger [this message]
2023-07-27 20:15 ` Michael Niedermayer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230727181552.13387-1-Reimar.Doeffinger@gmx.de \
--to=reimar.doeffinger@gmx.de \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git