Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] [RFC] tools/patcheck: portability fixes.
@ 2023-07-27 18:15 Reimar.Doeffinger
  2023-07-27 20:15 ` Michael Niedermayer
  0 siblings, 1 reply; 2+ messages in thread
From: Reimar.Doeffinger @ 2023-07-27 18:15 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Reimar Döffinger

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".

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [FFmpeg-devel] [PATCH] [RFC] tools/patcheck: portability fixes.
  2023-07-27 18:15 [FFmpeg-devel] [PATCH] [RFC] tools/patcheck: portability fixes Reimar.Doeffinger
@ 2023-07-27 20:15 ` Michael Niedermayer
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Niedermayer @ 2023-07-27 20:15 UTC (permalink / raw)
  To: FFmpeg development discussions and patches


[-- Attachment #1.1: Type: text/plain, Size: 1137 bytes --]

On Thu, Jul 27, 2023 at 08:15:52PM +0200, Reimar.Doeffinger@gmx.de wrote:
> 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(-)

making it work on more platforms is a good idea.
It seems still working here on ubuntu but i certainly dont know which
syntax constructs work where

[...]

thx
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Opposition brings concord. Out of discord comes the fairest harmony.
-- Heraclitus

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

[-- Attachment #2: Type: text/plain, Size: 251 bytes --]

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-07-27 20:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-27 18:15 [FFmpeg-devel] [PATCH] [RFC] tools/patcheck: portability fixes Reimar.Doeffinger
2023-07-27 20:15 ` Michael Niedermayer

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