Re: [PATCH v7 02/13] pack-objects: turn type and in_pack_type to bitfields

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux