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: AS53758 23.128.96.0/24 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,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id E4EC31F852 for ; Mon, 31 Jan 2022 17:13:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380758AbiAaRNU (ORCPT ); Mon, 31 Jan 2022 12:13:20 -0500 Received: from pb-smtp20.pobox.com ([173.228.157.52]:60341 "EHLO pb-smtp20.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380741AbiAaRNT (ORCPT ); Mon, 31 Jan 2022 12:13:19 -0500 Received: from pb-smtp20.pobox.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id 18315162B99; Mon, 31 Jan 2022 12:13:19 -0500 (EST) (envelope-from junio@pobox.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=sasl; bh=ne5xPykQlLNVdlZOVsXDzLz1V5Rf8noTq5oFpH UCITs=; b=fGCRt7himMVDmk89bMjwy4JknvubP7jACIcMDXueZNx+5tlfpzIx/h CJuUStVhKGKmPasMcXcAVGucdPXmZMGvLML4Zav7mB1rYkdYF8mf2CDvpwW3udFU /ygVdks4H2AiH/SdzqWdG7SDZIj5fEwz43jioUOFFuOW/1p1nibgY= Received: from pb-smtp20.sea.icgroup.com (unknown [127.0.0.1]) by pb-smtp20.pobox.com (Postfix) with ESMTP id F23DC162B98; Mon, 31 Jan 2022 12:13:18 -0500 (EST) (envelope-from junio@pobox.com) Received: from pobox.com (unknown [104.133.2.91]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp20.pobox.com (Postfix) with ESMTPSA id 61C8F162B97; Mon, 31 Jan 2022 12:13:16 -0500 (EST) (envelope-from junio@pobox.com) From: Junio C Hamano To: Han-Wen Nienhuys Cc: Patrick Steinhardt , git Subject: Re: flags types/names References: Date: Mon, 31 Jan 2022 09:13:15 -0800 In-Reply-To: (Han-Wen Nienhuys's message of "Mon, 31 Jan 2022 10:50:16 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Pobox-Relay-ID: 1461EBEC-82B9-11EC-8B33-C85A9F429DF0-77302942!pb-smtp20.pobox.com Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Han-Wen Nienhuys writes: > My questions: > > * am I the only one who struggles with the different flavor of `flags` ? Probably no. > * if no, what should be done about this? Maybe > > typedef unsigned int ref_flags; > #define REF_IS_SYMREF 0x1 > char *refs_resolve_ref_unsafe(const char *refname, ref_flags *flags, ... ); > > or > > typedef enum ref_flags { > REF_IS_SYMREF = 0x1, > }; > char *refs_resolve_ref_unsafe(const char *refname, enum ref_flags > *flags, ... ); It is very good to use symbolic constants implemented either as C preprocessor macros or enums, I would think. However, I am not enthused to see typedefs; I've never seen multiple typedefs of the same integral type did anything useful in C. Perhaps things are different in the C++ land, but we do not live there. > A somewhat related gripe is that some code uses `int flags` and other > code uses `unsigned flags`. It would be great to standardize this. I agree. Unless there is very compelling reason to single out the topmost bit and treat it as special, a set of flag bits should be "unsigned".