From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 669A54382A for ; Wed, 30 Nov 2022 22:06:48 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8731368B7BA; Thu, 1 Dec 2022 00:06:45 +0200 (EET) Received: from mail-ed1-f44.google.com (mail-ed1-f44.google.com [209.85.208.44]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 23C9F680B98 for ; Thu, 1 Dec 2022 00:06:40 +0200 (EET) Received: by mail-ed1-f44.google.com with SMTP id r26so23800642edc.10 for ; Wed, 30 Nov 2022 14:06:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=sKXa2JE6kLHLbjxfs1P5AmGGXSBZf3IWEOHTfS+50a8=; b=I6DEAOobQqfold13krArAd+jqhMQsQCV4YnWY5JJsY7J0Y5QgJo4yc5H2G6nvUxbcb U2XGtyNJmavLMscy/ioLUoahTcN4wYhy1WRbwakCf5WYcSUIQNAHsi6q0LNZY8Z21bCJ TIebtY7UAQ41Wm5eJt15+5k7SYFq6VRGdJacykUMgwV3gvRQh+/6x6f1azdGWbSbL1IO mkTt2u2FneOf3CMWSdtdO7MF/oofGnBgKXEMT9L3QMlxtghB3ropm+SRNsMq1iECCZhR X28ehZvkUqezI1rtKKGC7oImTMzfuZ1w5TXSiOeWxAvO/23dFYXbvq+PamAE+c4iA3sB TGwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding: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=sKXa2JE6kLHLbjxfs1P5AmGGXSBZf3IWEOHTfS+50a8=; b=Z7xGdi4YiAT36K+kbog6zLtxZTX2IjsQIUDU576780FoWvxNlKgSaqyya1rW61iw3u FXtlgPE89wTayIk9g9/tDWDCwjEapbRgAOQh6i7PKd0z/rA7VQC/MCWPxTqGPUEVDfxI Qmy6dQJi//iBUfoM/swELwm4+XF3MgLzGj/P6RLBkc0VMHHocrne/dj7+Rfpvi/hvEW6 8V41amlrMEwu5WU/eAqB6dogzGNmVag2YoFZuB8ZbcIaZkrcQ+bgp83R7OKEzJ06MpsR BvrT+t6FIXMWGQ8obu+ePxQ2mKc275SaATQlBRUxW1fvX1Ht6p8uusXqyJPf7B50az9V Trxg== X-Gm-Message-State: ANoB5plAJefCR/zxBkEgrrkdls0NQyWUlKXcGI+/AzNqvFaIHCC3MAT3 tKchxZvvCzi+Z/Xi6khR/krSqU72pQs= X-Google-Smtp-Source: AA0mqf57UmnrMSFXkOq0GvDzdS4vEgdcw0Exizz5FggaGTCX0Nco3JfkaS5DkgO1DeUHcRc8QjaO8Q== X-Received: by 2002:a05:6402:f10:b0:467:9976:2e37 with SMTP id i16-20020a0564020f1000b0046799762e37mr58308686eda.267.1669845999455; Wed, 30 Nov 2022 14:06:39 -0800 (PST) Received: from [192.168.1.104] (84-112-104-25.cable.dynamic.surfer.at. [84.112.104.25]) by smtp.gmail.com with ESMTPSA id m22-20020a170906721600b007bb86679a32sm1065564ejk.217.2022.11.30.14.06.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Nov 2022 14:06:38 -0800 (PST) From: Marvin Scholz To: FFmpeg development discussions and patches Date: Wed, 30 Nov 2022 23:06:37 +0100 X-Mailer: MailMate (1.14r5898) Message-ID: In-Reply-To: <0bfac0d8-25e2-af99-e508-e57112a3a3bc@gmail.com> References: <20221125013046.40904-1-epirat07@gmail.com> <20221126144648.73162-1-epirat07@gmail.com> <20221126144648.73162-8-epirat07@gmail.com> <0bfac0d8-25e2-af99-e508-e57112a3a3bc@gmail.com> MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH v2 07/31] avutil: use av_dict_iterate 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 27 Nov 2022, at 16:06, James Almer wrote: > On 11/26/2022 11:46 AM, Marvin Scholz wrote: >> --- >> libavutil/opt.c | 12 ++++++------ >> libavutil/tests/dict.c | 2 +- >> 2 files changed, 7 insertions(+), 7 deletions(-) >> >> diff --git a/libavutil/opt.c b/libavutil/opt.c >> index a3940f47fb..0a909a8b22 100644 >> --- a/libavutil/opt.c >> +++ b/libavutil/opt.c >> @@ -1742,14 +1742,14 @@ void av_opt_free(void *obj) >> int av_opt_set_dict2(void *obj, AVDictionary **options, int search_flags) >> { >> - AVDictionaryEntry *t = NULL; >> + const AVDictionaryEntry *t = NULL; >> AVDictionary *tmp = NULL; >> int ret; >> if (!options) >> return 0; >> - while ((t = av_dict_get(*options, "", t, AV_DICT_IGNORE_SUFFIX))) { >> + while ((t = av_dict_iterate(*options, t))) { >> ret = av_opt_set(obj, t->key, t->value, search_flags); >> if (ret == AVERROR_OPTION_NOT_FOUND) >> ret = av_dict_set(&tmp, t->key, t->value, 0); >> @@ -2137,16 +2137,16 @@ FF_ENABLE_DEPRECATION_WARNINGS >> case AV_OPT_TYPE_DICT: { >> AVDictionary *dict1 = NULL; >> AVDictionary *dict2 = *(AVDictionary **)dst; >> - AVDictionaryEntry *en1 = NULL; >> - AVDictionaryEntry *en2 = NULL; >> + const AVDictionaryEntry *en1 = NULL; >> + const AVDictionaryEntry *en2 = NULL; >> ret = av_dict_parse_string(&dict1, o->default_val.str, "=", ":", 0); >> if (ret < 0) { >> av_dict_free(&dict1); >> return ret; >> } >> do { >> - en1 = av_dict_get(dict1, "", en1, AV_DICT_IGNORE_SUFFIX); >> - en2 = av_dict_get(dict2, "", en2, AV_DICT_IGNORE_SUFFIX); >> + en1 = av_dict_iterate(dict1, en1); >> + en2 = av_dict_iterate(dict2, en2); >> } while (en1 && en2 && !strcmp(en1->key, en2->key) && !strcmp(en1->value, en2->value)); >> av_dict_free(&dict1); >> return (!en1 && !en2); >> diff --git a/libavutil/tests/dict.c b/libavutil/tests/dict.c >> index d053545f4d..91567289c2 100644 >> --- a/libavutil/tests/dict.c >> +++ b/libavutil/tests/dict.c >> @@ -52,7 +52,7 @@ static void test_separators(const AVDictionary *m, const char pair, const char v >> int main(void) >> { >> AVDictionary *dict = NULL; >> - AVDictionaryEntry *e; >> + const AVDictionaryEntry *e; > > Spurious change? You're not touching the test otherwise. Oh indeed!. > > In any case, feel free to add the following to this patch: > >> diff --git a/libavutil/tests/dict.c b/libavutil/tests/dict.c >> index d053545f4d..468391a9f3 100644 >> --- a/libavutil/tests/dict.c >> +++ b/libavutil/tests/dict.c >> @@ -52,7 +52,7 @@ static void test_separators(const AVDictionary *m, const char pair, const char v >> int main(void) >> { >> AVDictionary *dict = NULL; >> - AVDictionaryEntry *e; >> + const AVDictionaryEntry *e; >> char *buffer = NULL; >> >> printf("Testing av_dict_get_string() and av_dict_parse_string()\n"); >> @@ -94,8 +94,13 @@ int main(void) >> if (av_dict_get(dict, NULL, NULL, 0)) >> printf("av_dict_get() does not correctly handle NULL key.\n"); >> e = NULL; >> + printf("Iterating with av_dict_get()\n"); >> while ((e = av_dict_get(dict, "", e, AV_DICT_IGNORE_SUFFIX))) >> printf("%s %s\n", e->key, e->value); >> + e = NULL; >> + printf("Iterating with av_dict_iterate()\n"); >> + while ((e = av_dict_iterate(dict, e))) >> + printf("%s %s\n", e->key, e->value); >> av_dict_free(&dict); >> >> if (av_dict_set(&dict, NULL, "a", 0) >= 0 || >> diff --git a/tests/ref/fate/dict b/tests/ref/fate/dict >> index 7205e4c845..a519b49163 100644 >> --- a/tests/ref/fate/dict >> +++ b/tests/ref/fate/dict >> @@ -30,6 +30,14 @@ ret 0 >> aaa aaa bbb bbb ccc ccc \,='" \,='" >> >> Testing av_dict_set() >> +Iterating with av_dict_get() >> +a a >> +b b >> +c c >> +d d >> +e e >> +ff ff >> +Iterating with av_dict_iterate() >> a a >> b b >> c c > > That should be enough to compare the output of both functions. I see, thanks. Do you want to apply this change to the patch when merging saving an unnecessary round trip to the ML? > _______________________________________________ > 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".