Skip to contentSkip to conversation

common: fix compiler warning on wrong printf format

PATCH Superseded Alexey Brodkin 2 participants 4 messages Aug 28, 2014

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 common: fix compiler warning on wrong printf format

From: Alexey Brodkin <[email protected]>

bounce_buffer->len_aligned is of type "size_t" so use "%zd".

this fixes following warning:
--->---
common/bouncebuf.c: In function "addr_aligned":
common/bouncebuf.c:26:3: warning: format "%d" expects argument of type "int", but argument 2 has type "size_t" [-Wformat=]
debug("Unaligned buffer length %d\n", /*(int)*/state->len);
^
--->---

Cc Vasili Galka <[email protected]>
Cc Tom Rini <[email protected]>
cc Chris Packham <[email protected]>

---
Compared to v1 proper format (%zd) is used in string instead of type casting.

---
 common/bouncebuf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
common/bouncebuf.c +1 -1
index 9eece6d..8dde8fd 100644
@@ -23,7 +23,7 @@ static int addr_aligned(struct bounce_buffer *state)
 
 	/* Check if length is aligned */
 	if (state->len != state->len_aligned) {
-		debug("Unaligned buffer length %d\n", state->len);
+		debug("Unaligned buffer length %zd\n", state->len);
 		return 0;
 	}
 
Signature · 1 line
1.9.3
#1 lore raw

PATCH v2 1/1 common: fix compiler warning on wrong printf format

On Thu, Aug 28, 2014 at 4:15 PM, Alexey Brodkin <[email protected]

Quoted 40 lines

wrote:

From: Alexey Brodkin <[email protected]>

bounce_buffer->len_aligned is of type "size_t" so use "%zd".

this fixes following warning:
--->---
common/bouncebuf.c: In function "addr_aligned":
common/bouncebuf.c:26:3: warning: format "%d" expects argument of type "int", but argument 2 has type "size_t" [-Wformat=]

   debug("Unaligned buffer length %d\n", /*(int)*/state->len);
   ^

--->---

Cc Vasili Galka <[email protected]>
Cc Tom Rini <[email protected]>
cc Chris Packham <[email protected]>

---
Compared to v1 proper format (%zd) is used in string instead of type casting.

---
 common/bouncebuf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
common/bouncebuf.c +1 -2
index 9eece6d..8dde8fd 100644
@@ -23,7 +23,7 @@ static int addr_aligned(struct bounce_buffer *state)
 
        /* Check if length is aligned */
        if (state->len != state->len_aligned) {
-               debug("Unaligned buffer length %d\n", state->len);
+               debug("Unaligned buffer length %zd\n", state->len);
                return 0;
        }
 
--
Quoted 3 lines

1.9.3

Hmm, why not just use my original patch which included exactly this?
http://patchwork.ozlabs.org/patch/383041/

#2 lore raw

PATCH v2 1/1 common: fix compiler warning on wrong printf format

Hi Vasili,

Quoted 15 lines · Vasili Galka

On Thu, Aug 28, 2014 at 4:15 PM, Alexey Brodkin <[email protected]> wrote:
From: Alexey Brodkin <[email protected]>

bounce_buffer->len_aligned is of type "size_t" so use "%zd".

this fixes following warning:
--->---
common/bouncebuf.c: In function "addr_aligned":
common/bouncebuf.c:26:3: warning: format "%d" expects argument of type "int", but argument 2 has type "size_t" [-Wformat=]
debug("Unaligned buffer length %d\n", /*(int)*/state->len); ^
--->---

Quoted 3 lines

Hmm, why not just use my original patch which included exactly this?
http://patchwork.ozlabs.org/patch/383041/

Well, I'm not following all the messages sent to this mailing list so didn't know about your patch.

So as soon as I observed a problem I created a patch and sent it.

I see your patch fixes more things so definitely it should be applied instead.

Sorry for noise.

-Alexey

#3 lore raw

PATCH v2 1/1 common: fix compiler warning on wrong printf format

Quoted 25 lines · Alexey Brodkin

Hi Vasili,

Quoted 15 lines · Vasili Galka

On Thu, Aug 28, 2014 at 4:15 PM, Alexey Brodkin <[email protected]> wrote:
From: Alexey Brodkin <[email protected]>

bounce_buffer->len_aligned is of type "size_t" so use "%zd".

this fixes following warning:
--->---
common/bouncebuf.c: In function "addr_aligned":
common/bouncebuf.c:26:3: warning: format "%d" expects argument of type "int", but argument 2 has type "size_t" [-Wformat=]
debug("Unaligned buffer length %d\n", /*(int)*/state->len); ^
--->---

Quoted 3 lines

Hmm, why not just use my original patch which included exactly this?
http://patchwork.ozlabs.org/patch/383041/

Well, I'm not following all the messages sent to this mailing list so didn't know about your patch.

Quoted 9 lines

So as soon as I observed a problem I created a patch and sent it.

I see your patch fixes more things so definitely it should be applied instead.

Sorry for noise.

-Alexey

Oh, I thought you Cc'ed me because you seen it but decided to fix it in alternative way.
Never mind, MY applogies for the noise :-)

Best,
Vasili