* [PATCH v2] xen: Fix implicit type conversion
@ 2021-10-26 7:32 Jiasheng Jiang
2021-10-26 7:36 ` Juergen Gross
0 siblings, 1 reply; 4+ messages in thread
From: Jiasheng Jiang @ 2021-10-26 7:32 UTC (permalink / raw)
To: boris.ostrovsky, jgross, sstabellini
Cc: xen-devel, linux-kernel, Jiasheng Jiang
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 <jiasheng@iscas.ac.cn>
---
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] xen: Fix implicit type conversion
2021-10-26 7:32 [PATCH v2] xen: Fix implicit type conversion Jiasheng Jiang
@ 2021-10-26 7:36 ` Juergen Gross
2021-10-26 9:59 ` Jiamei Xie
0 siblings, 1 reply; 4+ messages in thread
From: Juergen Gross @ 2021-10-26 7:36 UTC (permalink / raw)
To: Jiasheng Jiang, boris.ostrovsky, sstabellini; +Cc: xen-devel, linux-kernel
[-- Attachment #1.1.1: Type: text/plain, Size: 701 bytes --]
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 <jiasheng@iscas.ac.cn>
Reviewed-by: Juergen Gross <jgross@suse.com>
Juergen
[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3135 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH v2] xen: Fix implicit type conversion
2021-10-26 7:36 ` Juergen Gross
@ 2021-10-26 9:59 ` Jiamei Xie
2021-10-27 13:21 ` Boris Ostrovsky
0 siblings, 1 reply; 4+ messages in thread
From: Jiamei Xie @ 2021-10-26 9:59 UTC (permalink / raw)
To: Juergen Gross, Jiasheng Jiang, boris.ostrovsky, sstabellini
Cc: xen-devel, linux-kernel
> -----Original Message-----
> From: Xen-devel <xen-devel-bounces@lists.xenproject.org> On Behalf Of
> Juergen Gross
> Sent: 2021年10月26日 15:36
> To: Jiasheng Jiang <jiasheng@iscas.ac.cn>; boris.ostrovsky@oracle.com;
> sstabellini@kernel.org
> Cc: xen-devel@lists.xenproject.org; linux-kernel@vger.kernel.org
> 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 <jiasheng@iscas.ac.cn>
>
> Reviewed-by: Juergen Gross <jgross@suse.com>
>
>
> Juergen
[Jiamei Xie]
Reviewed-by: Jiamei Xie <jiamei.xie@arm.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] xen: Fix implicit type conversion
2021-10-26 9:59 ` Jiamei Xie
@ 2021-10-27 13:21 ` Boris Ostrovsky
0 siblings, 0 replies; 4+ messages in thread
From: Boris Ostrovsky @ 2021-10-27 13:21 UTC (permalink / raw)
To: Jiamei Xie, Juergen Gross, Jiasheng Jiang, sstabellini
Cc: xen-devel, linux-kernel
On 10/26/21 5:59 AM, Jiamei Xie wrote:
>
>> -----Original Message-----
>> From: Xen-devel <xen-devel-bounces@lists.xenproject.org> On Behalf Of
>> Juergen Gross
>> Sent: 2021年10月26日 15:36
>> To: Jiasheng Jiang <jiasheng@iscas.ac.cn>; boris.ostrovsky@oracle.com;
>> sstabellini@kernel.org
>> Cc: xen-devel@lists.xenproject.org; linux-kernel@vger.kernel.org
>> 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 <jiasheng@iscas.ac.cn>
>> Reviewed-by: Juergen Gross <jgross@suse.com>
>>
>>
>> Juergen
> [Jiamei Xie]
> Reviewed-by: Jiamei Xie <jiamei.xie@arm.com>
Applied to for-linus-5.16
-boris
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-10-27 13:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-26 7:32 [PATCH v2] xen: Fix implicit type conversion Jiasheng Jiang
2021-10-26 7:36 ` Juergen Gross
2021-10-26 9:59 ` Jiamei Xie
2021-10-27 13:21 ` Boris Ostrovsky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®