Re: [PATCH v3 6/8] ACPI: property: Unify integer value reading functions

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

 



On Wed, May 25, 2022 at 04:01:21PM +0300, Sakari Ailus wrote:
> Unify functions reading ACPI property integer values into a single macro
> using C99 _Generic().
> 
> Also use size_t for the counter instead of int.

Thanks for an update!

...

> +#define acpi_copy_property_array_uint(items, val, nval)			\
> +	({								\

You can define local copies of (read-only) parameters and avoid adding
parentheses each time you access them.

> +		size_t i;						\
> +		int ret = 0;						\
> +									\
> +		for (i = 0; i < (nval); i++) {				\
> +			if ((items)[i].type != ACPI_TYPE_INTEGER) {	\
> +				ret = -EPROTO;				\
> +				break;					\
> +			}						\
> +			if ((items)[i].integer.value > _Generic((val),	\
> +								u8: U8_MAX, \
> +								u16: U16_MAX, \
> +								u32: U32_MAX, \
> +								u64: U64_MAX, \
> +								default: 0U)) { \

I think nobody will die if you add one more TAB to each line and make \ be
consistent column wise.

> +				ret = -EOVERFLOW;			\
> +				break;					\
> +			}						\
> +									\
> +			(val)[i] = (items)[i].integer.value;		\
> +		}							\
> +		ret;							\
> +	})

-- 
With Best Regards,
Andy Shevchenko





[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux