Skip to contentSkip to conversation

ACPI: apei: Cast u64 to unsigned long, fix compile warning

PATCH In review Javier Martinez Canillas 3 participants 3 messages Sep 12, 2010 – Sep 14, 2010

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ACPI: apei: Cast u64 to unsigned long, fix compile warning

In today linux-net I got a compile warning in acpi/apei

drivers/acpi/apei/erst.c: In function ‘erst_exec_move_data’:
drivers/acpi/apei/erst.c:273: warning: cast to pointer from integer of different size drivers/acpi/apei/erst.c:274: warning: cast to pointer from integer of different size

The problem is that apei_exec_context->dst_base type is u64. But in 32 bits architecture void * is 32 bits long. Casting it to unsigned long solves the issue

---
 drivers/acpi/apei/erst.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/acpi/apei/erst.c +2 -2
index a4904f1..37d7a05 100644
@@ -270,8 +270,8 @@ static int erst_exec_move_data(struct apei_exec_context *ctx,
 	rc = __apei_exec_read_register(entry, &offset);
 	if (rc)
 		return rc;
-	memmove((void *)ctx->dst_base + offset,
-		(void *)ctx->src_base + offset,
+	memmove((void *)(unsigned long)ctx->dst_base + offset,
+		(void *)(unsigned long)ctx->src_base + offset,
 		ctx->var2);
 
 	return 0;
Signature · 1 line
1.7.0.4
#1 lore raw
Quoted 20 lines · On Sun, 12 Sep 2010 09:48:25 -0400 Javier Martinez Canillas…

In today linux-net I got a compile warning in acpi/apei

drivers/acpi/apei/erst.c: In function ___erst_exec_move_data___:
drivers/acpi/apei/erst.c:273: warning: cast to pointer from integer of different size drivers/acpi/apei/erst.c:274: warning: cast to pointer from integer of different size

The problem is that apei_exec_context->dst_base type is u64. But in 32 bits architecture void * is 32 bits long. Casting it to unsigned long solves the issue

---
 drivers/acpi/apei/erst.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/acpi/apei/erst.c +0 -0
index a4904f1..37d7a05 100644

drivers/acpi/apei/erst.c static int erst_exec_move_data(struct apei_exec_context *ctx, · line 277

Quoted 10 lines
drivers/acpi/apei/erst.c +2 -2
@@ -270,8 +270,8 @@ static int erst_exec_move_data(struct apei_exec_context *ctx,
 	rc = __apei_exec_read_register(entry, &offset);
 	if (rc)
 		return rc;
-	memmove((void *)ctx->dst_base + offset,
-		(void *)ctx->src_base + offset,
+	memmove((void *)(unsigned long)ctx->dst_base + offset,
+		(void *)(unsigned long)ctx->src_base + offset,
 		ctx->var2);
 
 	return 0;

This might indicate that the incorrect types were used within the `struct apei_exec_context'. I can't tell (or can't be bothered working it out), because whoever wrote that didn't bother documenting any of it at all.

Are those things kernel virtual addresses? If so, a pointer type should have been used.

#2 lore raw

Hi, Andrew,

Quoted 32 lines · Andrew Morton
Quoted 29 lines · On Sun, 12 Sep 2010 09:48:25 -0400 Javier Martinez Canillas…

In today linux-net I got a compile warning in acpi/apei

drivers/acpi/apei/erst.c: In function ___erst_exec_move_data___:
drivers/acpi/apei/erst.c:273: warning: cast to pointer from integer of different size drivers/acpi/apei/erst.c:274: warning: cast to pointer from integer of different size

The problem is that apei_exec_context->dst_base type is u64. But in 32 bits architecture void * is 32 bits long. Casting it to unsigned long solves the issue

---
 drivers/acpi/apei/erst.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/acpi/apei/erst.c +2 -2
index a4904f1..37d7a05 100644
@@ -270,8 +270,8 @@ static int erst_exec_move_data(struct apei_exec_context *ctx,
 	rc = __apei_exec_read_register(entry, &offset);
 	if (rc)
 		return rc;
-	memmove((void *)ctx->dst_base + offset,
-		(void *)ctx->src_base + offset,
+	memmove((void *)(unsigned long)ctx->dst_base + offset,
+		(void *)(unsigned long)ctx->src_base + offset,
 		ctx->var2);
 
Quoted 6 lines

drivers/acpi/apei/erst.c static int erst_exec_move_data(struct apei_exec_context *ctx, · line 277

Quoted 1 line
drivers/acpi/apei/erst.c +0 -0
 	return 0;

This might indicate that the incorrect types were used within the `struct apei_exec_context'. I can't tell (or can't be bothered working it out), because whoever wrote that didn't bother documenting any of it at all.

Sorry about lacking the document. All these code are based on ACPI specification 4.0a, section 17.5 "Error Serialization". The fields in struct apei_exec_context such as var1, var2, src_base, dst_base, etc come from there too. I will add some document for it.

Quoted 2 lines

Are those things kernel virtual addresses? If so, a pointer type should have been used.

Sorry, I found another bug here. These should be physical memory and should be ioremapped before accessing. I will fix it as soon as possible.

Best Regards,
Huang Ying