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 076DD46BF8 for ; Tue, 8 Aug 2023 07:14:31 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CD98268C4B5; Tue, 8 Aug 2023 10:14:28 +0300 (EEST) Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com [209.85.208.174]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6922C68C336 for ; Tue, 8 Aug 2023 10:14:22 +0300 (EEST) Received: by mail-lj1-f174.google.com with SMTP id 38308e7fff4ca-2ba1e9b1fa9so59242491fa.3 for ; Tue, 08 Aug 2023 00:14:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691478861; x=1692083661; h=user-agent:in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date:from:to:cc :subject:date:message-id:reply-to; bh=K+tmREW8py6UWymBkdKq/cydTUHpQsYfYEa3vCi49qA=; b=EqjEgkeDvZEsqBfbFrjr/Z5XBHq25WFQMSIa4T+EKaFCVL8HfLrFhSiw28pkpTNXgY 79do4+xTlSjYeY/j1ZU5Ikv1CkJnCEeAJ07sLjvpEZlzcOjJWDZ+aOlgYILQjb7sKWFW Pogw92/H7IbaoTW7cIYvJjVOTjLmi31XwKM8hMJGnvqyEau2RUIFQctFDGcB9UTMsEC6 92rHA0Mppq+BXtFD0Zbaq3SHZSYN3etPjY/flgh7oWBaSs9EpGeNGfamZsN90nAx51PW uZm0tejMoO3+vec9Kx0YWBjy9okmaEIRUbqMnNT+ueqm3n2+hzQWSRNM35nfMfczmKv7 l5MA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691478861; x=1692083661; h=user-agent:in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=K+tmREW8py6UWymBkdKq/cydTUHpQsYfYEa3vCi49qA=; b=C7nYIegTJ2d+BcnrsjopWCnHtlUTZq/V6hNtHe2Gt0pOqt3gBdZ7FTI4s56xICxYjT s5lsWEkVXeRNpDnK+rUEy5nr1L1smUEFRShMv8YwJtley11yJ4PeZz2l8fM+bXoEXJmw BDUFEAdlMVdXBGdU9/EqPYy39C5jNO9xBgzn2SHvAJF8SqcJrHKVfYzGBmqogl9GSFh0 swJRjZ3751C2xcpg/LiRBg/G2H9vMmtsEmDOIV9/RAGazN4JnxqriqMYrAWoMXXhlIx8 V46otT63//NlmzwaCT7fSI+0JM8L3/4snmT5fm72Qxqbg0DbUCNcdcflnPNp+AfMYbDn WfHQ== X-Gm-Message-State: AOJu0YxhNtCvVT3YNBXNxyuBnZVejZ2iJVzdFCsxLk+J6725Z2Nm0lly CWAEu8wqYyBfsayiDjgxC38J0zh65ec= X-Google-Smtp-Source: AGHT+IGD5ItWXZul4crbHie+m+IrTHR0iTFpNtIFp1tn8Eum9DPaoUuGzNw5hHTt3h9hBJWpEFrS0w== X-Received: by 2002:a05:651c:227:b0:2b9:eeaa:1072 with SMTP id z7-20020a05651c022700b002b9eeaa1072mr8866448ljn.18.1691478860673; Tue, 08 Aug 2023 00:14:20 -0700 (PDT) Received: from mariano (dynamic-adsl-84-220-37-107.clienti.tiscali.it. [84.220.37.107]) by smtp.gmail.com with ESMTPSA id k18-20020a5d5192000000b003143b7449ffsm12639197wrv.25.2023.08.08.00.14.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Aug 2023 00:14:19 -0700 (PDT) Received: by mariano (Postfix, from userid 1000) id 53FC1BFB73; Tue, 8 Aug 2023 09:14:18 +0200 (CEST) Date: Tue, 8 Aug 2023 09:14:18 +0200 From: Stefano Sabatini To: FFmpeg development discussions and patches Message-ID: <20230808071418.GA4305@mariano> Mail-Followup-To: FFmpeg development discussions and patches , Andreas Rheinhardt References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.13.2 (2019-12-18) Subject: Re: [FFmpeg-devel] [PATCH] fftools/ffprobe: Use proper enum type 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: Andreas Rheinhardt 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 date Sunday 2023-08-06 15:28:00 +0200, Andreas Rheinhardt wrote: > This is a bit cleaner as int need not be the underlying type > of an enum if a smaller type can hold all its values. > Also declare the children_ids array as const as it never changes. > > Signed-off-by: Andreas Rheinhardt > --- > fftools/ffprobe.c | 38 ++++++++++++++++++-------------------- > 1 file changed, 18 insertions(+), 20 deletions(-) > > diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c > index 5c2d4cbff1..4fcfe1164b 100644 > --- a/fftools/ffprobe.c > +++ b/fftools/ffprobe.c > @@ -161,22 +161,6 @@ static int find_stream_info = 1; > > #define SECTION_MAX_NB_CHILDREN 10 > > -struct section { > - int id; ///< unique id identifying a section > - const char *name; > - > -#define SECTION_FLAG_IS_WRAPPER 1 ///< the section only contains other sections, but has no data at its own level > -#define SECTION_FLAG_IS_ARRAY 2 ///< the section contains an array of elements of the same type > -#define SECTION_FLAG_HAS_VARIABLE_FIELDS 4 ///< the section may contain a variable number of fields with variable keys. > - /// For these sections the element_name field is mandatory. > - int flags; > - int children_ids[SECTION_MAX_NB_CHILDREN+1]; ///< list of children section IDS, terminated by -1 > - const char *element_name; ///< name of the contained element, if provided > - const char *unique_name; ///< unique section name, in case the name is ambiguous > - AVDictionary *entries_to_show; > - int show_all_entries; > -}; > - > typedef enum { > SECTION_ID_NONE = -1, > SECTION_ID_CHAPTER, > @@ -229,6 +213,22 @@ typedef enum { > SECTION_ID_SUBTITLE, > } SectionID; > > +struct section { > + int id; ///< unique id identifying a section > + const char *name; > + > +#define SECTION_FLAG_IS_WRAPPER 1 ///< the section only contains other sections, but has no data at its own level > +#define SECTION_FLAG_IS_ARRAY 2 ///< the section contains an array of elements of the same type > +#define SECTION_FLAG_HAS_VARIABLE_FIELDS 4 ///< the section may contain a variable number of fields with variable keys. > + /// For these sections the element_name field is mandatory. > + int flags; > + const SectionID children_ids[SECTION_MAX_NB_CHILDREN+1]; ///< list of children section IDS, terminated by -1 > + const char *element_name; ///< name of the contained element, if provided > + const char *unique_name; ///< unique section name, in case the name is ambiguous > + AVDictionary *entries_to_show; > + int show_all_entries; > +}; > + > static struct section sections[] = { > [SECTION_ID_CHAPTERS] = { SECTION_ID_CHAPTERS, "chapters", SECTION_FLAG_IS_ARRAY, { SECTION_ID_CHAPTER, -1 } }, > [SECTION_ID_CHAPTER] = { SECTION_ID_CHAPTER, "chapter", 0, { SECTION_ID_CHAPTER_TAGS, -1 } }, > @@ -3688,8 +3688,7 @@ static inline void mark_section_show_entries(SectionID section_id, > > section->show_all_entries = show_all_entries; > if (show_all_entries) { > - SectionID *id; > - for (id = section->children_ids; *id != -1; id++) > + for (const SectionID *id = section->children_ids; *id != -1; id++) > mark_section_show_entries(*id, show_all_entries, entries); > } else { > av_dict_copy(§ion->entries_to_show, entries, 0); > @@ -4072,11 +4071,10 @@ static const OptionDef real_options[] = { > > static inline int check_section_show_entries(int section_id) > { > - int *id; > struct section *section = §ions[section_id]; > if (sections[section_id].show_all_entries || sections[section_id].entries_to_show) > return 1; > - for (id = section->children_ids; *id != -1; id++) > + for (const SectionID *id = section->children_ids; *id != -1; id++) I remember this might trigger a C90 style warning (mixed declarations and statements), make sure it's not the case anymore. > if (check_section_show_entries(*id)) > return 1; > return 0; > -- > 2.34.1 LGTM, thanks. _______________________________________________ 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".