From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 114094E9CB for ; Thu, 12 Jun 2025 17:07:24 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 1C9D768B6FB; Thu, 12 Jun 2025 20:07:21 +0300 (EEST) Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id 49D1F688FDB for ; Thu, 12 Jun 2025 20:07:14 +0300 (EEST) Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-451ebd3d149so8415005e9.2 for ; Thu, 12 Jun 2025 10:07:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1749748033; x=1750352833; darn=ffmpeg.org; h=mime-version:references:in-reply-to:message-id:date:subject:to:from :from:to:cc:subject:date:message-id:reply-to; bh=b87KVnFuYktqP/cFAo74Yelg4E/5o1gdpmRpjU7oKDI=; b=ZnapSSERpOlMHGTUw9aN4EoTDt6/hJ7c2xSVqs1GVJ9ellr/TiWnm+zgwnHDcf16GP oEoiC+WaQ5645SHjOK6BvG2WqM1Ibio0PCEsFYDXNVPAPBdHj5DVDcKyo6Qqe69DVWSu 1ovUazJ/lVNrwNAZGmawDfWX7bAfBBSgv1z3QMEgz6pIz8mxJsGYymhbQ/0qn0qnGG8m C+EIfStVX1mgkkzSNVisYGuFtyCnDFd4h3Tgu9g048WnqDekVFdszVoqerB0N3guFk8O R57uIV1AnwYdLVIKCHDxPJpI++u4n2um3luMD+0XLkrspuvOorMbqLc58VL/+vH7sG6D rX1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749748033; x=1750352833; h=mime-version:references:in-reply-to:message-id:date:subject:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=b87KVnFuYktqP/cFAo74Yelg4E/5o1gdpmRpjU7oKDI=; b=Ruh8LZ+ECSsFRKSx7atoLN/qtNbwnUH+BLdue4mfYMp3o4k/dPFmLQEg/4kpayzzeG 4PuozDpdT6bev4gULCDX8piPaBlZDGxN5HmHFzRqdzZ4II4mrHH5auKwBJmp8ge5Ng18 Z0KhBPmv5UhUYIWOgPs50/Ze2tiv4dZ73ocmuaXG8nFMm0e0OeYTnKZcMf6pTApCoIcy OdT0urEG2F227T0iJv63Fv2NZhWcBen6x5e4VWoxNXOYYPgoe20G0iN65nuyOxs3L3Du 5IVay0dwyScev2RVC3d7sxuCjgcWM8lgPO7IGj0ZgrQBPCEHsEgO+QLyBg5ow5svVYkb tm0A== X-Gm-Message-State: AOJu0YwvG9uToT/VPg0HLF6qfWRifZTysqTQnkiKKCPJ47J3BAdHelaM MfeiiAQNgoJp1gFgLRhLZHIdVZJMD0JUrpnZMf+4dgDDsnE328Ljh1kcu39e2g== X-Gm-Gg: ASbGncsdlTYJwQBeUlpGmZMe6jcEN54qrKNWwXhca4ZmWyDaxUMyEpITR/vrIxFk0fV UCAKwVFhOWaV8T9i7bz+p/gTXDO5wS1PbFhPioYtdlCUslPA4khT1oGxkZC5dx6dOVsGS/vSx8j 2MfA1I0VgwbeyoQ5vFMHV7x7XUB2agWgeRZLC6Ma7JOnSk6Ou1EzP8lDXzCMVG8CXV18GiZYCcK z7Bz9TaxaGEDL/Yq1KX18venF0N7ReFjt9qdihFZcjSZRAIgILH+HsPLZ+RRMUW/g4oIAPos1VZ 2OLDNlX7uTG/NDGc4dcmydX+okJtuZnAoyrDFq0L8QgVKigCS/tF02A3BUl14Uf2x6D16OxT70v RzhfWyP1O9e8usl5BgFDR+ixV7Av4w+mHDlzZ77MxZLkZYyaz4Z8qbJRzQpyxb+kelrtslMcq3m I= X-Google-Smtp-Source: AGHT+IHQUUiX1FBb3a4xiFaGnfYJW1aZ9g2UgQZW8KrGcqZW93DDb5YOf6AHWgF3h6Uzxsk4jZtSpw== X-Received: by 2002:a05:600c:3d9b:b0:43d:77c5:9c1a with SMTP id 5b1f17b1804b1-4533433008dmr5984635e9.4.1749748033399; Thu, 12 Jun 2025 10:07:13 -0700 (PDT) Received: from [192.168.178.57] (p200301023700450060f2a9d7350ce887.dip0.t-ipconnect.de. [2003:102:3700:4500:60f2:a9d7:350c:e887]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4532e241b70sm25930875e9.18.2025.06.12.10.07.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Jun 2025 10:07:12 -0700 (PDT) From: Marvin Scholz To: FFmpeg development discussions and patches Date: Thu, 12 Jun 2025 19:07:11 +0200 X-Mailer: MailMate (2.0r6222) Message-ID: <3E1D038D-815F-4914-89FA-18C3F99E6073@gmail.com> In-Reply-To: References: <20250611204213.97295-1-epirat07@gmail.com> <395F8F80-4C17-48A4-AD34-442029EF7D11@gmail.com> MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH 1/4] fftools/textformat: narrow variable scopes 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On 12 Jun 2025, at 18:10, softworkz . wrote: >> -----Original Message----- >> From: ffmpeg-devel On Behalf Of >> Marvin Scholz >> Sent: Donnerstag, 12. Juni 2025 13:25 >> To: FFmpeg development discussions and patches > devel@ffmpeg.org> >> Subject: Re: [FFmpeg-devel] [PATCH 1/4] fftools/textformat: narrow >> variable scopes >> >> >> >> On 12 Jun 2025, at 4:26, softworkz . wrote: >> >>> Hi Marvin, >>> >>>> -----Original Message----- >>>> From: ffmpeg-devel On Behalf >> Of >>>> Marvin Scholz >>>> Sent: Mittwoch, 11. Juni 2025 22:42 >>>> To: ffmpeg-devel@ffmpeg.org >>>> Subject: [FFmpeg-devel] [PATCH 1/4] fftools/textformat: narrow >>>> variable scopes >>>> >>>> --- >>>> fftools/textformat/avtextformat.c | 15 ++++++--------- >>>> 1 file changed, 6 insertions(+), 9 deletions(-) >>>> >>>> diff --git a/fftools/textformat/avtextformat.c >>>> b/fftools/textformat/avtextformat.c >>>> index 14779e6f0c..f1811abb1c 100644 >>>> --- a/fftools/textformat/avtextformat.c >>>> +++ b/fftools/textformat/avtextformat.c >>>> @@ -101,7 +101,6 @@ static void bprint_bytes(AVBPrint *bp, const >>>> uint8_t *ubuf, size_t ubuf_size) >>>> int avtext_context_close(AVTextFormatContext **ptctx) >>>> { >>>> AVTextFormatContext *tctx = *ptctx; >>>> - int i; >>>> int ret = 0; >>>> >>>> if (!tctx) >>>> @@ -117,7 +116,7 @@ int avtext_context_close(AVTextFormatContext >>>> **ptctx) >>>> if (tctx->formatter->priv_class) >>>> av_opt_free(tctx->priv); >>>> } >>>> - for (i = 0; i < SECTION_MAX_NB_LEVELS; i++) >>>> + for (int i = 0; i < SECTION_MAX_NB_LEVELS; i++) >>>> av_bprint_finalize(&tctx->section_pbuf[i], NULL); >>>> av_freep(&tctx->priv); >>>> av_opt_free(tctx); >>>> @@ -130,7 +129,7 @@ int avtext_context_open(AVTextFormatContext >>>> **ptctx, const AVTextFormatter *form >>>> const AVTextFormatSection *sections, >> int >>>> nb_sections, AVTextFormatOptions options, char *show_data_hash) >>>> { >>>> AVTextFormatContext *tctx; >>>> - int i, ret = 0; >>>> + int ret = 0; >>>> >>>> av_assert0(ptctx && formatter); >>>> >>>> @@ -202,7 +201,7 @@ int avtext_context_open(AVTextFormatContext >>>> **ptctx, const AVTextFormatter *form >>>> if (ret == AVERROR(EINVAL)) { >>>> const char *n; >>>> av_log(NULL, AV_LOG_ERROR, "Unknown hash >> algorithm >>>> '%s'\nKnown algorithms:", show_data_hash); >>>> - for (i = 0; (n = av_hash_names(i)); i++) >>>> + for (unsigned i = 0; (n = av_hash_names(i)); >> i++) >>>> av_log(NULL, AV_LOG_ERROR, " %s", n); >>>> av_log(NULL, AV_LOG_ERROR, "\n"); >>>> } >>>> @@ -525,13 +524,13 @@ void avtext_print_data(AVTextFormatContext >>>> *tctx, const char *key, >>>> { >>>> AVBPrint bp; >>>> unsigned offset = 0; >>>> - int l, i; >>>> + int i; >>>> >>>> av_bprint_init(&bp, 0, AV_BPRINT_SIZE_UNLIMITED); >>>> av_bprintf(&bp, "\n"); >>>> while (size) { >>>> av_bprintf(&bp, "%08x: ", offset); >>>> - l = FFMIN(size, 16); >>>> + int l = FFMIN(size, 16); >>>> for (i = 0; i < l; i++) { >>>> av_bprintf(&bp, "%02x", data[i]); >>>> if (i & 1) >>>> @@ -571,7 +570,6 @@ void >> avtext_print_integers(AVTextFormatContext >>>> *tctx, const char *key, >>>> { >>>> AVBPrint bp; >>>> unsigned offset = 0; >>>> - int l, i; >>>> >>>> if (!key || !data || !format || columns <= 0 || bytes <= 0) >>>> return; >>>> @@ -580,8 +578,7 @@ void >> avtext_print_integers(AVTextFormatContext >>>> *tctx, const char *key, >>>> av_bprintf(&bp, "\n"); >>>> while (size) { >>>> av_bprintf(&bp, "%08x: ", offset); >>>> - l = FFMIN(size, columns); >>>> - for (i = 0; i < l; i++) { >>>> + for (int i = 0, l = FFMIN(size, columns); i < l; i++) { >>> >>> You are changing behavior here because size is changed inside the >> loop. >>> The pre-evaluation into l is intentional. >>> >> >> I fail to see how I change anything here though? It is still just >> assigned before >> the loop runs, just that l is scoped narrower? > > This is the original code: > > l = FFMIN(size, columns); > for (i = 0; i < l; i++) { > if (bytes == 1) av_bprintf(&bp, format, *data); > else if (bytes == 2) av_bprintf(&bp, format, AV_RN16(data)); > else if (bytes == 4) av_bprintf(&bp, format, AV_RN32(data)); > data += bytes; > size--; > } > > See the size-- ? > I see that but again I fail to see how this changes anything. I am not changing that l is assigned before the loop runs, just narrow the scope to the loop. See: https://godbolt.org/z/c3hGKfne4 > > Thanks > sw > > > > > > > > _______________________________________________ > 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". _______________________________________________ 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".