linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RESEND] scsi: ultrastor: Use correct format identifier for kernel pointer
@ 2016-05-01 21:54 William Breathitt Gray
  0 siblings, 0 replies; 4+ messages in thread
From: William Breathitt Gray @ 2016-05-01 21:54 UTC (permalink / raw)
  To: JBottomley; +Cc: linux-scsi, linux-kernel

The 'bios_segment' member of a struct ultrastor_config is passed to the
sprintf function with a respective %05X format identifier. The
'bio_segment' member is a kernel pointer, but the %X format identifier
expects an int data type. A cast to int is correctly used to satisfy the
format identifier, but this assumes that the int data type is the same
size as the kernel pointer, which is not the case on several
architectures such as X86_64. This patch removes the int cast and
replaces the %05X format identifier with %pK in order to print the
'bio_segment' member regardless of architecture.

Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
---
 drivers/scsi/ultrastor.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/ultrastor.c b/drivers/scsi/ultrastor.c
index 14e0c40..2e99f98 100644
--- a/drivers/scsi/ultrastor.c
+++ b/drivers/scsi/ultrastor.c
@@ -670,12 +670,12 @@ static const char *ultrastor_info(struct Scsi_Host * shpnt)
       sprintf(buf, "UltraStor 24F SCSI @ Slot %u IRQ%u",
 	      config.slot, config.interrupt);
     else if (config.subversion)
-      sprintf(buf, "UltraStor 34F SCSI @ Port %03X BIOS %05X IRQ%u",
-	      config.port_address, (int)config.bios_segment,
+      sprintf(buf, "UltraStor 34F SCSI @ Port %03X BIOS %pK IRQ%u",
+	      config.port_address, config.bios_segment,
 	      config.interrupt);
     else
-      sprintf(buf, "UltraStor 14F SCSI @ Port %03X BIOS %05X IRQ%u DMA%u",
-	      config.port_address, (int)config.bios_segment,
+      sprintf(buf, "UltraStor 14F SCSI @ Port %03X BIOS %pK IRQ%u DMA%u",
+	      config.port_address, config.bios_segment,
 	      config.interrupt, config.dma_channel);
     return buf;
 }
-- 
2.7.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH RESEND] scsi: ultrastor: Use correct format identifier for kernel pointer
  2016-05-01 23:08 ` James Bottomley
@ 2016-05-01 23:18   ` William Breathitt Gray
  0 siblings, 0 replies; 4+ messages in thread
From: William Breathitt Gray @ 2016-05-01 23:18 UTC (permalink / raw)
  To: James Bottomley; +Cc: martin.petersen, linux-scsi, linux-kernel

On Sun, May 01, 2016 at 04:08:25PM -0700, James Bottomley wrote:
>On Sun, 2016-05-01 at 17:57 -0400, William Breathitt Gray wrote:
>> The 'bios_segment' member of a struct ultrastor_config is passed to the
>> sprintf function with a respective %05X format identifier. The
>> 'bio_segment' member is a kernel pointer, but the %X format identifier
>> expects an int data type. A cast to int is correctly used to satisfy the
>> format identifier, but this assumes that the int data type is the same
>> size as the kernel pointer, which is not the case on several
>> architectures such as X86_64. This patch removes the int cast and
>> replaces the %05X format identifier with %pK in order to print the
>> 'bio_segment' member regardless of architecture.
>
>But this statement is wrong: ultrastor only has seven possible hard
>coded bios segment values, all under 20 bits, as it happens, that's why
>the printk is %05X.  Unless you're proposing to alter values in the
>static table, there's no point in changing the print, is there?  Are
>you proposing to alter the static table values?
>
>James

I'm sorry, I didn't realize bios_segment values were all under 20 bits;
in which case they should all fit within the original 5 digit
hexadecimal print. Please ignore this patch then as it was a
misunderstanding on my part.

Thanks,

William Breathitt Gray

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH RESEND] scsi: ultrastor: Use correct format identifier for kernel pointer
  2016-05-01 21:57 William Breathitt Gray
@ 2016-05-01 23:08 ` James Bottomley
  2016-05-01 23:18   ` William Breathitt Gray
  0 siblings, 1 reply; 4+ messages in thread
From: James Bottomley @ 2016-05-01 23:08 UTC (permalink / raw)
  To: William Breathitt Gray, martin.petersen; +Cc: linux-scsi, linux-kernel

On Sun, 2016-05-01 at 17:57 -0400, William Breathitt Gray wrote:
> The 'bios_segment' member of a struct ultrastor_config is passed to the
> sprintf function with a respective %05X format identifier. The
> 'bio_segment' member is a kernel pointer, but the %X format identifier
> expects an int data type. A cast to int is correctly used to satisfy the
> format identifier, but this assumes that the int data type is the same
> size as the kernel pointer, which is not the case on several
> architectures such as X86_64. This patch removes the int cast and
> replaces the %05X format identifier with %pK in order to print the
> 'bio_segment' member regardless of architecture.

But this statement is wrong: ultrastor only has seven possible hard
coded bios segment values, all under 20 bits, as it happens, that's why
the printk is %05X.  Unless you're proposing to alter values in the
static table, there's no point in changing the print, is there?  Are
you proposing to alter the static table values?

James

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH RESEND] scsi: ultrastor: Use correct format identifier for kernel pointer
@ 2016-05-01 21:57 William Breathitt Gray
  2016-05-01 23:08 ` James Bottomley
  0 siblings, 1 reply; 4+ messages in thread
From: William Breathitt Gray @ 2016-05-01 21:57 UTC (permalink / raw)
  To: jejb, martin.petersen; +Cc: linux-scsi, linux-kernel

The 'bios_segment' member of a struct ultrastor_config is passed to the
sprintf function with a respective %05X format identifier. The
'bio_segment' member is a kernel pointer, but the %X format identifier
expects an int data type. A cast to int is correctly used to satisfy the
format identifier, but this assumes that the int data type is the same
size as the kernel pointer, which is not the case on several
architectures such as X86_64. This patch removes the int cast and
replaces the %05X format identifier with %pK in order to print the
'bio_segment' member regardless of architecture.

Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
---
 drivers/scsi/ultrastor.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/ultrastor.c b/drivers/scsi/ultrastor.c
index 14e0c40..2e99f98 100644
--- a/drivers/scsi/ultrastor.c
+++ b/drivers/scsi/ultrastor.c
@@ -670,12 +670,12 @@ static const char *ultrastor_info(struct Scsi_Host * shpnt)
       sprintf(buf, "UltraStor 24F SCSI @ Slot %u IRQ%u",
 	      config.slot, config.interrupt);
     else if (config.subversion)
-      sprintf(buf, "UltraStor 34F SCSI @ Port %03X BIOS %05X IRQ%u",
-	      config.port_address, (int)config.bios_segment,
+      sprintf(buf, "UltraStor 34F SCSI @ Port %03X BIOS %pK IRQ%u",
+	      config.port_address, config.bios_segment,
 	      config.interrupt);
     else
-      sprintf(buf, "UltraStor 14F SCSI @ Port %03X BIOS %05X IRQ%u DMA%u",
-	      config.port_address, (int)config.bios_segment,
+      sprintf(buf, "UltraStor 14F SCSI @ Port %03X BIOS %pK IRQ%u DMA%u",
+	      config.port_address, config.bios_segment,
 	      config.interrupt, config.dma_channel);
     return buf;
 }
-- 
2.7.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-05-01 23:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-01 21:54 [PATCH RESEND] scsi: ultrastor: Use correct format identifier for kernel pointer William Breathitt Gray
2016-05-01 21:57 William Breathitt Gray
2016-05-01 23:08 ` James Bottomley
2016-05-01 23:18   ` William Breathitt Gray

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).