Skip to contentSkip to conversation

sdhci: use PRIx64 for uint64_t type

PATCH Superseded Sai Pavan Boddu 3 participants 6 messages Sep 5, 2015 – Sep 6, 2015

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 sdhci: use PRIx64 for uint64_t type

Fix compile time warnings, because of type mismatch for unsigned long long type.

---
Changes for V2:
Fix commit message.
Correct line lenght.

---
 hw/sd/sdhci.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
hw/sd/sdhci.c +5 -2
index 2469077..639feee 100644
@@ -22,6 +22,7 @@
  * with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <inttypes.h>
 #include "hw/hw.h"
 #include "sysemu/block-backend.h"
 #include "sysemu/blockdev.h"
@@ -719,7 +720,8 @@ static void sdhci_do_adma(SDHCIState *s)
             break;
         case SDHC_ADMA_ATTR_ACT_LINK:   /* link to next descriptor table */
             s->admasysaddr = dscr.addr;
-            DPRINT_L1("ADMA link: admasysaddr=0x%lx\n", s->admasysaddr);
+            DPRINT_L1("ADMA link: admasysaddr=0x%" PRIx64 "\n",
+                      s->admasysaddr);
             break;
         default:
             s->admasysaddr += dscr.incr;
@@ -727,7 +729,8 @@ static void sdhci_do_adma(SDHCIState *s)
         }
 
         if (dscr.attr & SDHC_ADMA_ATTR_INT) {
-            DPRINT_L1("ADMA interrupt: admasysaddr=0x%lx\n", s->admasysaddr);
+            DPRINT_L1("ADMA interrupt: admasysaddr=0x%" PRIx64 "\n",
+                      s->admasysaddr);
             if (s->norintstsen & SDHC_NISEN_DMA) {
                 s->norintsts |= SDHC_NIS_DMA;
             }
Signature · 1 line
1.9.1
#1 lore raw
Quoted 15 lines · Sai Pavan Boddu

Fix compile time warnings, because of type mismatch for unsigned long long type.

---
Changes for V2:
Fix commit message.
Correct line lenght.
---

hw/sd/sdhci.c +1 -0
+#include <inttypes.h>
 #include "hw/hw.h"
 #include "sysemu/block-backend.h"
 #include "sysemu/blockdev.h"

hw/sd/sdhci.c static void sdhci_do_adma(SDHCIState *s) · line 724

Quoted 6 lines
hw/sd/sdhci.c +2 -1
@@ -719,7 +720,8 @@ static void sdhci_do_adma(SDHCIState *s)
             break;
         case SDHC_ADMA_ATTR_ACT_LINK:   /* link to next descriptor table */
             s->admasysaddr = dscr.addr;
-            DPRINT_L1("ADMA link: admasysaddr=0x%lx\n", s->admasysaddr);
+            DPRINT_L1("ADMA link: admasysaddr=0x%" PRIx64 "\n",
+                      s->admasysaddr);

Please also fix the real problem. This sort of bitrot will keep occurring unless DPRINT_L1() is fixed to unconditionally compile its arguments. In other words, do something like:

#define DPRINT_L1(fmt, ...) \
    do { \
        if (SDHC_DEBUG) { \
            fprintf(stderr, "QEMU SDHC: " fmt, ##__VA_ARGS__); \
        } \
    } while (0)
#define DPRINT_L2(fmt, ...) \
    do { \
        if (SDHC_DEBUG > 1) { \
            fprintf(stderr, "QEMU SDHC: " fmt, ##__VA_ARGS__); \
        } \
    } while (0)
#define ERRPRINT(fmt, ...) \
    do {
        if (SDHC_DEBUG) { \
            fprintf(stderr, "QEMU SDHC ERROR: " fmt, ##__VA_ARGS__); \
        } \
    } while (0)

rather than the current junk that eliminates the fprintf entirely when SDHC_DEBUG is at its default of 0.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#2 lore raw
Quoted 11 lines · Eric Blake
Quoted 9 lines · Sai Pavan Boddu

Fix compile time warnings, because of type mismatch for unsigned long long type.

---
Changes for V2:
Fix commit message.
Correct line lenght.
---

Quoted 16 lines

hw/sd/sdhci.c static void sdhci_do_adma(SDHCIState *s) · line 724

Quoted 11 lines
hw/sd/sdhci.c +3 -1
+#include <inttypes.h>
 #include "hw/hw.h"
 #include "sysemu/block-backend.h"
 #include "sysemu/blockdev.h"
@@ -719,7 +720,8 @@ static void sdhci_do_adma(SDHCIState *s)
             break;
         case SDHC_ADMA_ATTR_ACT_LINK:   /* link to next descriptor table */
             s->admasysaddr = dscr.addr;
-            DPRINT_L1("ADMA link: admasysaddr=0x%lx\n", s->admasysaddr);
+            DPRINT_L1("ADMA link: admasysaddr=0x%" PRIx64 "\n",
+                      s->admasysaddr);

Please also fix the real problem. This sort of bitrot will keep occurring unless DPRINT_L1() is fixed to unconditionally compile its arguments. In other words, do something like:

This isn't strictly needed for this patch, but I see the point. Pavan do you want to respin as a 2P series or do this as follow up?

Regards,
Peter

Quoted 27 lines
#define DPRINT_L1(fmt, ...) \
    do { \
        if (SDHC_DEBUG) { \
            fprintf(stderr, "QEMU SDHC: " fmt, ##__VA_ARGS__); \
        } \
    } while (0)
#define DPRINT_L2(fmt, ...) \
    do { \
        if (SDHC_DEBUG > 1) { \
            fprintf(stderr, "QEMU SDHC: " fmt, ##__VA_ARGS__); \
        } \
    } while (0)
#define ERRPRINT(fmt, ...) \
    do {
        if (SDHC_DEBUG) { \
            fprintf(stderr, "QEMU SDHC ERROR: " fmt, ##__VA_ARGS__); \
        } \
    } while (0)

rather than the current junk that eliminates the fprintf entirely when SDHC_DEBUG is at its default of 0.

--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org

#3 lore raw
In reply to Eric Blake
Quoted 56 lines

-----Original Message-----
From: Eric Blake [mailto:[email protected]]
Sent: Saturday, September 05, 2015 6:12 PM
To: Sai Pavan Boddu; [email protected]; [email protected]; [email protected]
Cc: Sai Pavan Boddu; Edgar Iglesias; Alistair Francis
Subject: Re: [Qemu-devel] [PATCH V2] sdhci: use PRIx64 for uint64_t type

Quoted 15 lines · Sai Pavan Boddu

Fix compile time warnings, because of type mismatch for unsigned long long type.

---
Changes for V2:
Fix commit message.
Correct line lenght.
---

hw/sd/sdhci.c +1 -0
+#include <inttypes.h>
 #include "hw/hw.h"
 #include "sysemu/block-backend.h"
 #include "sysemu/blockdev.h"

hw/sd/sdhci.c static void sdhci_do_adma(SDHCIState *s) · line 724

Quoted 6 lines
hw/sd/sdhci.c +2 -1
@@ -719,7 +720,8 @@ static void sdhci_do_adma(SDHCIState *s)
             break;
         case SDHC_ADMA_ATTR_ACT_LINK:   /* link to next descriptor table */
             s->admasysaddr = dscr.addr;
-            DPRINT_L1("ADMA link: admasysaddr=0x%lx\n", s->admasysaddr);
+            DPRINT_L1("ADMA link: admasysaddr=0x%" PRIx64 "\n",
+                      s->admasysaddr);

Please also fix the real problem. This sort of bitrot will keep occurring unless DPRINT_L1() is fixed to unconditionally compile its arguments. In other words, do something like:

#define DPRINT_L1(fmt, ...) \
    do { \
        if (SDHC_DEBUG) { \
            fprintf(stderr, "QEMU SDHC: " fmt, ##__VA_ARGS__); \
        } \
    } while (0)
#define DPRINT_L2(fmt, ...) \
    do { \
        if (SDHC_DEBUG > 1) { \
            fprintf(stderr, "QEMU SDHC: " fmt, ##__VA_ARGS__); \
        } \
    } while (0)
#define ERRPRINT(fmt, ...) \
    do {
        if (SDHC_DEBUG) { \
            fprintf(stderr, "QEMU SDHC ERROR: " fmt, ##__VA_ARGS__); \
        } \
    } while (0)
Quoted 2 lines

rather than the current junk that eliminates the fprintf entirely when SDHC_DEBUG is at its default of 0.

[Sai Pavan ] Yeah, never thought about this. Your suggestion will help in preventing many issue like the same. I will fix this!!

Thanks,
Sai Pavan.

Quoted 5 lines

--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Reviewed-by on v2 1/1
#4 lore raw
In reply to Sai Pavan Boddu
Quoted 4 lines · Sai Pavan Boddu

Fix compile time warnings, because of type mismatch for unsigned long long type.

Quoted 43 lines

---
Changes for V2:
Fix commit message.
Correct line lenght.

---
 hw/sd/sdhci.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
hw/sd/sdhci.c +5 -3
index 2469077..639feee 100644
@@ -22,6 +22,7 @@
  * with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <inttypes.h>
 #include "hw/hw.h"
 #include "sysemu/block-backend.h"
 #include "sysemu/blockdev.h"
@@ -719,7 +720,8 @@ static void sdhci_do_adma(SDHCIState *s)
             break;
         case SDHC_ADMA_ATTR_ACT_LINK:   /* link to next descriptor table */
             s->admasysaddr = dscr.addr;
-            DPRINT_L1("ADMA link: admasysaddr=0x%lx\n", s->admasysaddr);
+            DPRINT_L1("ADMA link: admasysaddr=0x%" PRIx64 "\n",
+                      s->admasysaddr);
             break;
         default:
             s->admasysaddr += dscr.incr;
@@ -727,7 +729,8 @@ static void sdhci_do_adma(SDHCIState *s)
         }
 
         if (dscr.attr & SDHC_ADMA_ATTR_INT) {
-            DPRINT_L1("ADMA interrupt: admasysaddr=0x%lx\n", s->admasysaddr);
+            DPRINT_L1("ADMA interrupt: admasysaddr=0x%" PRIx64 "\n",
+                      s->admasysaddr);
             if (s->norintstsen & SDHC_NISEN_DMA) {
                 s->norintsts |= SDHC_NIS_DMA;
             }
--

1.9.1

#5 lore raw

Hi Peter,

Quoted 8 lines

-----Original Message-----
From: Peter Crosthwaite [mailto:[email protected]]
Sent: Sunday, September 06, 2015 12:03 AM
To: Sai Pavan Boddu
Cc: [email protected] Developers; Peter Maydell; Alistair Francis; Edgar Iglesias; Sai Pavan Boddu
Subject: Re: [PATCH V2] sdhci: use PRIx64 for uint64_t type

Quoted 8 lines
Quoted 4 lines · Sai Pavan Boddu

Fix compile time warnings, because of type mismatch for unsigned long long type.

[Sai Pavan ] Thanks :), I will even send out V3_2P, closing on Eric comments.

Regards,
Sai Pavan

Quoted 45 lines
Quoted 45 lines

---
Changes for V2:
Fix commit message.
Correct line lenght.

---
 hw/sd/sdhci.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
hw/sd/sdhci.c +5 -2
index 2469077..639feee 100644
@@ -22,6 +22,7 @@
  * with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <inttypes.h>
 #include "hw/hw.h"
 #include "sysemu/block-backend.h"
 #include "sysemu/blockdev.h"
@@ -719,7 +720,8 @@ static void sdhci_do_adma(SDHCIState *s)
             break;
         case SDHC_ADMA_ATTR_ACT_LINK:   /* link to next descriptor table */
             s->admasysaddr = dscr.addr;
-            DPRINT_L1("ADMA link: admasysaddr=0x%lx\n", s->admasysaddr);
+            DPRINT_L1("ADMA link: admasysaddr=0x%" PRIx64 "\n",
+                      s->admasysaddr);
             break;
         default:
             s->admasysaddr += dscr.incr;
@@ -727,7 +729,8 @@ static void sdhci_do_adma(SDHCIState *s)
         }
 
         if (dscr.attr & SDHC_ADMA_ATTR_INT) {
-            DPRINT_L1("ADMA interrupt: admasysaddr=0x%lx\n", s-
 admasysaddr);
+            DPRINT_L1("ADMA interrupt: admasysaddr=0x%" PRIx64 "\n",
+                      s->admasysaddr);
             if (s->norintstsen & SDHC_NISEN_DMA) {
                 s->norintsts |= SDHC_NIS_DMA;
             }

--
1.9.1