From patchwork Thu Jul 27 18:15:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Reimar_D=C3=B6ffinger?= X-Patchwork-Id: 43007 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:7927:b0:130:ccc6:6c4b with SMTP id b39csp158486pzg; Thu, 27 Jul 2023 11:16:07 -0700 (PDT) X-Google-Smtp-Source: APBJJlEJQCC7umEyklZugb9wexoBJ5YJkjTrHKdFLJDQqITCVR87NUILEr/NcBdbvGWGV/HJA++r X-Received: by 2002:a17:906:2092:b0:994:3207:cde3 with SMTP id 18-20020a170906209200b009943207cde3mr3092423ejq.49.1690481767466; Thu, 27 Jul 2023 11:16:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690481767; cv=none; d=google.com; s=arc-20160816; b=TuWqoTxmZqrM1LLOnGyKlXjtssdyzrsoZ7qWenqGWHuTRL/HtoE3Q0qFXExiKVt3+8 SPMmBVAFuwnltXooicKfEUaQNmHxBB7lYrUbp35+7BguXXmKKXBt2GLJQOA0+8etzurH 0UjLLyJgk/wSVpjLQ7ezVJjPgtathp20dHx7mV/XOusnJkDGjmck8+u8MN5qRmEPWrRa EeSaCN2iPFOhN1eb1JD5USpiznxZB4v36RrEdim7ZxBkuv/lMbLcb+9oQOB0zrX2fLx8 +PxHHDZD17NVvoU/jtvW2Vn/DFhQ65HQU7ZGQln9xfFOTaFahfjPZF3fV9WlWKlJh4ZU 8iag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:ui-outboundreport:mime-version :message-id:date:to:from:delivered-to; bh=hH8R1AgScXtpUpsHDoIQzgFYMElEUmNb8EAhpfYh9c4=; fh=fXcCBasH1NfrAloNC1XA9V9ZOn3lYYHy05Aa/Q2POE4=; b=KKTaTopVF8E95Z3PgPRQO/tWDRcZZBbxZrWNXplhC5K/Pd445NzDi8fCD/924V32lu bFHe/Q7lliEzYIk8vgOOW6aMj//hg5FGn404UEpAXT+lLvOY56bachHscJA0iyxWPxl0 A3wTBFKX1hrtBEq4ShTVJOonIoviKQT6o2adCmA3SDknlWMVWVq7GXrQCoORafBq/hFy xZg6nmi/oPyYOuxU5dvt91w1jHNI/ZHA8/MQmaiw298H3apskojQyLkFoT9GXi1QpxO2 XIi/vE+E+SsEtC+IP3QSVfPM9J0IVo3/dQIfJ8YY4HN7/M5EwfGpbJlnuJNVbiR0Zco8 SdTQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.de Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id sb11-20020a170906edcb00b0098d2f81bceasi1461648ejb.934.2023.07.27.11.16.06; Thu, 27 Jul 2023 11:16:07 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 705F468CA84; Thu, 27 Jul 2023 21:16:03 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.135]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1930568C632 for ; Thu, 27 Jul 2023 21:15:56 +0300 (EEST) Received: from Reimars-Air.fritz.box ([155.4.74.59]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.167]) with ESMTPSA (Nemesis) id 1N1x6X-1pjTN411zd-012Dq7; Thu, 27 Jul 2023 20:15:55 +0200 From: Reimar.Doeffinger@gmx.de To: ffmpeg-devel@ffmpeg.org Date: Thu, 27 Jul 2023 20:15:52 +0200 Message-Id: <20230727181552.13387-1-Reimar.Doeffinger@gmx.de> X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) MIME-Version: 1.0 X-Provags-ID: V03:K1:m4zY3FqcrlBpi+2j9r0GYL6+p6ppiudtCUcgvl8++vPlqqLcouS gk9S9TlIexI61Ue/CX+T8Tb9ZPbW0am74PvGI9R6+YjRxsB6oVo6Z5qBt4VJEYth2FS6pBP /HPexF89aVH02R4mVcIwmVpBwSruuh5fhKJ3+iTlCrrznU+wJEfN8BXscbWxD2EsccpMQfg SGoeIa2VtPPTkIdY7cgvw== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:Ydy/d8oefZA=;nYKxdSdEJKp2rvSN3T6q2flfI0F YXLlYGhGoF3mQIxILHyIPTlR+2fpkPz7v9uWVE5zJqhDi2xFIrx5F3IQ/mugrmtB243xyBXzy DvR8//e1x3o7/eKwFLsOfJuWPgMsXl/hAjVZnxYEXOJQ5fdOgVvbtWadDRZJQfM7HrubNrWpj 0q0XyyHJtwO7cR/Zx7qAkCTcih+gv9Yd6fJB2NgvjBkQvsxSdhjED8pUJi+PQ1YTMpNpYPIqe IsUVJqHn5iC3jvEPOQYf0ZtVLXQZWfIPzZL4J06TsW7iM1/tRzJ0y7kJ/oesn1wgmQGS354zj bY7/T04rEIVPTtvUvCtLgPrfVA7IQ3YsLsHjOEodbZ6fHCEB0Y0phveNonNQXVJYBxCtUOwCr 4ip0adIcJrVq/XfFM01adAGeLCytTpwzEi+z/DTFJNTFL0ROprQohjhj8HgrJhWpIEVdjjT67 UQondyoBjJRGuXwJGFCXdyb60/Zf8F5eSCdEkSa1v6mDMe16MBfiLvzvT097yvw7ekySfdSm8 NNdG1uPFoQXPyDWjT8QgctiWET+4O4jeIm+sQhngUyMtrBubeTx43UNMzro4Ixgb+6sBcaMF9 g/xsRRcJ2eCI7qZCxkNMZLJmUJFjDjf/krv1cst7mo+fzSjnRTZtGSM/MKjjRgl7OzwM9hiwX VTd28eUls0Z5dflTGHnDqt2wpy4S7Jfulk0Qi72CcrQBHoIefPrfR+U8/Za6hNx8KHPULP78c ny+OobpSOQkmVyN0yOJgalpEJnfO1bB7i09FlA5FDUl3ZkZA7rMeItaF3l0HtBtt+OVF2GDtI jI2jLL9FmWGKifYQMuVwVylSJPeSsvSSpH3WBCTADb5hlttrJgAY/8psBloIOTPiWfRf1PCHA 163wnRlWRfNgLTw== Subject: [FFmpeg-devel] [PATCH] [RFC] tools/patcheck: portability fixes. X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: =?utf-8?q?Reimar_D=C3=B6ffinger?= Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: ZXRCKAA4BQOW From: Reimar Döffinger 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"