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

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

 



On Fri, May 20, 2022 at 09:11:46AM +0300, Sakari Ailus wrote:
> Unify functions reading ACPI property integer values into a single macro,
> and call that macro to generate the functions for each bit depth.
> 
> Also use size_t for the counter instead of int.

...

> +#define DECLARE_ACPI_PROPERTY_COPY(bits)				\
> +	static int							\
> +	acpi_copy_property_array_u##bits(const union acpi_object *items, \

Personally I find much better if function templates in macros are not indented
additionally.

> +					 u##bits *val, size_t nval)	\
> +	{								\
> +		size_t i;						\
> +									\
> +		for (i = 0; i < nval; i++) {				\
> +			if (items[i].type != ACPI_TYPE_INTEGER)		\
> +				return -EPROTO;				\
> +			if (items[i].integer.value > U##bits##_MAX)	\
> +				return -EOVERFLOW;			\
> +									\
> +			val[i] = items[i].integer.value;		\
> +		}							\
> +		return 0;						\
>  	}

On top of that, we use a minimum compiler that supports _Generic(). Why not to
use it?

-- 
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