From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-4.0 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id 5FED61F619 for ; Wed, 26 Feb 2020 03:03:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729395AbgBZDDR (ORCPT ); Tue, 25 Feb 2020 22:03:17 -0500 Received: from pb-smtp21.pobox.com ([173.228.157.53]:63603 "EHLO pb-smtp21.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727880AbgBZDDR (ORCPT ); Tue, 25 Feb 2020 22:03:17 -0500 Received: from pb-smtp21.pobox.com (unknown [127.0.0.1]) by pb-smtp21.pobox.com (Postfix) with ESMTP id 44836B3843; Tue, 25 Feb 2020 22:03:15 -0500 (EST) (envelope-from junio@pobox.com) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=sasl; bh=kR7l07JXyx70kYYXV8kMv44D6hU=; b=ZNHyks fExh1LtTyvPnfe0JtnrNmn+kS9QXbrEzXMXHaw6QwLAqKjf8yhVsKkMEwdeYqHix uION2CzQzt3I4u2fhHgx1wnMFdnP8wUx6IFxkDwZX/XDym7rh2H1rRWu8/UmPdmz g5Ov/TATGF2Vv8fjUziAxN8NFMBRrygM/eKTo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=sasl; b=hlEDCB/2lAYnA/2ATUMVAaaIoF0cw1el nPVkpLId/xR+2BiFbLGghcJudFm6Dg/4DZEoto6CV3mhk38Z8wYTzuKHdN7xaS79 xVyG+JZDFgrUUEbYCDj6SzP4xoSeEys5efkllxmntBQIDnVqxlWw9aRzV2XZ8k/l QKtVXf7hry4= Received: from pb-smtp21.sea.icgroup.com (unknown [127.0.0.1]) by pb-smtp21.pobox.com (Postfix) with ESMTP id 3DA91B3842; Tue, 25 Feb 2020 22:03:15 -0500 (EST) (envelope-from junio@pobox.com) Received: from pobox.com (unknown [34.76.80.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp21.pobox.com (Postfix) with ESMTPSA id 64F18B3840; Tue, 25 Feb 2020 22:03:12 -0500 (EST) (envelope-from junio@pobox.com) From: Junio C Hamano To: Heba Waly Cc: Heba Waly via GitGitGadget , Git Mailing List Subject: Re: [PATCH v5 2/3] advice: revamp advise API References: Date: Tue, 25 Feb 2020 19:03:10 -0800 In-Reply-To: (Heba Waly's message of "Wed, 26 Feb 2020 13:37:36 +1300") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Pobox-Relay-ID: 8668CC98-5844-11EA-827D-8D86F504CC47-77302942!pb-smtp21.pobox.com Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Heba Waly writes: > I'm not against this approach as well, but as I mentioned above, we > need a list of keys to be returned by list_config_advices(), that's > why defining the constant strings will not be sufficient in our case. Sorry, but I do not get it. Either you use enum or a bunch of variables of type const char [], "list all of them" would need an array whose elements are all of them, so const char ADVICE_FOO[] = "advice.foo"; const char ADVICE_BAR[] = "advice.bar"; ... static const char *all_advice_type[] = { ADVICE_FOO, ADVICE_BAR, ... }; void for_each_advice_type(int (*fn)(const char *name)) { int i; for (i = 0; i < ARRAY_SIZE(all_advice_type); i++) fn(all_advice_type[i]); } would be sufficient, and I do not think it takes any more effort to create and manage than using an array indexed with the enum, no?