[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH RFC] CODING_STYLE: document intended usage of types
>>> On 21.02.18 at 16:34, <George.Dunlap@xxxxxxxxxxxxx> wrote: > On Mon, Feb 19, 2018 at 8:44 AM, Jan Beulich <JBeulich@xxxxxxxx> wrote: >> +When signedness matters, qualify plain char, short, int, long, and >> +long long with "signed" or "unsigned". Signedness is specifically >> +considered to matter when the valid value range of a variable covers >> +only non-negative values. The prime example of such is a variable used >> +to index an array (negative array indexes, while they may occur, are >> +rather rare). > > This paragraph is a bit confusing. You say "when signedeness > matters", which I would interpret as saying, "When it matters whether > you use signed or unsigned values". But is there ever a situation > where it doesn't matter whether we use signed or unsigned? Yes, if the value range is limited. That's why many people use (and are taught to use) plain int and long for things like loop variables, even if only positive values will be iterated over. Hence - "signed" and "unsigned" should be used to tell apart cases where their omission was simply because of not following the rule of - "unsigned" should be used when the valid value range is non- negative Perhaps I should distinguish "matters for correctness" from "matters for quality of generated code". It is the former case where I'd prefer "signed" to be made explicit. Jan _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |