From: Jeff King Date: Fri, 30 Mar 2018 20:18:32 GMT Subject: Re: [PATCH v7 02/13] pack-objects: turn type and in_pack_type to bitfields Message-ID: <20180330201832.GA14782@sigill.intra.peff.net> In-Reply-To: <20180324063353.24722-3-pclouds@gmail.com> On Sat, Mar 24, 2018 at 07:33:42AM +0100, Nguyễn Thái Ngọc Duy wrote: > +static inline void oe_set_type(struct object_entry *e, > + enum object_type type) > +{ > + if (type >= OBJ_ANY) > + die("BUG: OBJ_ANY cannot be set in pack-objects code"); A minor nit, but this (and other new assertions) should probably be BUG(). > + e->type_valid = type >= OBJ_NONE; > + e->type_ = (unsigned)type; Hmm, so if !e->type_valid, then we may write utter garbage into e->type_. That's OK, since everybody will access it via oe_type(), but I wonder if we could trigger weird compiler behavior. I guess the unsigned cast makes the truncation well-defined. -Peff