2021-10-26 07:44:56

by Jiasheng Jiang

[permalink] [raw]
Subject: [PATCH v2] xen: Fix implicit type conversion

The variable 'i' is defined as UINT.
However in the for_each_possible_cpu, its value is assigned to -1.
That doesn't make sense and in the cpumask_next() it is implicitly
type conversed to INT.
It is universally accepted that the implicit type conversion is
terrible.
Also, having the good programming custom will set an example for
others.
Thus, it might be better to change the definition of 'i' from UINT
to INT.

Fixes: 3fac101 ("xen: Re-upload processor PM data to hypervisor after S3 resume (v2)")
Signed-off-by: Jiasheng Jiang <[email protected]>
---
drivers/xen/xen-acpi-processor.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/xen/xen-acpi-processor.c b/drivers/xen/xen-acpi-processor.c
index df7cab8..9cb61db 100644
--- a/drivers/xen/xen-acpi-processor.c
+++ b/drivers/xen/xen-acpi-processor.c
@@ -450,7 +450,7 @@ static struct acpi_processor_performance __percpu *acpi_perf_data;

static void free_acpi_perf_data(void)
{
- unsigned int i;
+ int i;

/* Freeing a NULL pointer is OK, and alloc_percpu zeroes. */
for_each_possible_cpu(i)
@@ -462,7 +462,7 @@ static void free_acpi_perf_data(void)
static int xen_upload_processor_pm_data(void)
{
struct acpi_processor *pr_backup = NULL;
- unsigned int i;
+ int i;
int rc = 0;

pr_info("Uploading Xen processor PM info\n");
@@ -518,7 +518,7 @@ static struct syscore_ops xap_syscore_ops = {

static int __init xen_acpi_processor_init(void)
{
- unsigned int i;
+ int i;
int rc;

if (!xen_initial_domain())
--
2.7.4


2021-10-26 07:46:01

by Jürgen Groß

[permalink] [raw]
Subject: Re: [PATCH v2] xen: Fix implicit type conversion

On 26.10.21 09:32, Jiasheng Jiang wrote:
> The variable 'i' is defined as UINT.
> However in the for_each_possible_cpu, its value is assigned to -1.
> That doesn't make sense and in the cpumask_next() it is implicitly
> type conversed to INT.
> It is universally accepted that the implicit type conversion is
> terrible.
> Also, having the good programming custom will set an example for
> others.
> Thus, it might be better to change the definition of 'i' from UINT
> to INT.
>
> Fixes: 3fac101 ("xen: Re-upload processor PM data to hypervisor after S3 resume (v2)")
> Signed-off-by: Jiasheng Jiang <[email protected]>

Reviewed-by: Juergen Gross <[email protected]>


Juergen


Attachments:
OpenPGP_0xB0DE9DD628BF132F.asc (3.06 kB)
OpenPGP public key
OpenPGP_signature (505.00 B)
OpenPGP digital signature
Download all attachments

2021-10-26 12:59:41

by Jiamei Xie

[permalink] [raw]
Subject: RE: [PATCH v2] xen: Fix implicit type conversion



> -----Original Message-----
> From: Xen-devel <[email protected]> On Behalf Of
> Juergen Gross
> Sent: 2021年10月26日 15:36
> To: Jiasheng Jiang <[email protected]>; [email protected];
> [email protected]
> Cc: [email protected]; [email protected]
> Subject: Re: [PATCH v2] xen: Fix implicit type conversion
>
> On 26.10.21 09:32, Jiasheng Jiang wrote:
> > The variable 'i' is defined as UINT.
> > However in the for_each_possible_cpu, its value is assigned to -1.
> > That doesn't make sense and in the cpumask_next() it is implicitly
> > type conversed to INT.
> > It is universally accepted that the implicit type conversion is
> > terrible.
> > Also, having the good programming custom will set an example for
> > others.
> > Thus, it might be better to change the definition of 'i' from UINT
> > to INT.
> >
> > Fixes: 3fac101 ("xen: Re-upload processor PM data to hypervisor after S3
> resume (v2)")
> > Signed-off-by: Jiasheng Jiang <[email protected]>
>
> Reviewed-by: Juergen Gross <[email protected]>
>
>
> Juergen

[Jiamei Xie]
Reviewed-by: Jiamei Xie <[email protected]>

2021-10-27 21:26:19

by Boris Ostrovsky

[permalink] [raw]
Subject: Re: [PATCH v2] xen: Fix implicit type conversion


On 10/26/21 5:59 AM, Jiamei Xie wrote:
>
>> -----Original Message-----
>> From: Xen-devel <[email protected]> On Behalf Of
>> Juergen Gross
>> Sent: 2021年10月26日 15:36
>> To: Jiasheng Jiang <[email protected]>; [email protected];
>> [email protected]
>> Cc: [email protected]; [email protected]
>> Subject: Re: [PATCH v2] xen: Fix implicit type conversion
>>
>> On 26.10.21 09:32, Jiasheng Jiang wrote:
>>> The variable 'i' is defined as UINT.
>>> However in the for_each_possible_cpu, its value is assigned to -1.
>>> That doesn't make sense and in the cpumask_next() it is implicitly
>>> type conversed to INT.
>>> It is universally accepted that the implicit type conversion is
>>> terrible.
>>> Also, having the good programming custom will set an example for
>>> others.
>>> Thus, it might be better to change the definition of 'i' from UINT
>>> to INT.
>>>
>>> Fixes: 3fac101 ("xen: Re-upload processor PM data to hypervisor after S3
>> resume (v2)")
>>> Signed-off-by: Jiasheng Jiang <[email protected]>
>> Reviewed-by: Juergen Gross <[email protected]>
>>
>>
>> Juergen
> [Jiamei Xie]
> Reviewed-by: Jiamei Xie <[email protected]>



Applied to for-linus-5.16


-boris