Skip to contentSkip to conversation

Fixed dump_buffer function parameter offset does not take effect

PATCH In review lichun 2 participants 2 messages Apr 5, 2019

lore
Share & tools
lore

lichun

author
#0 lore raw

PATCH 1/1 Fixed dump_buffer function parameter offset does not take effect

---
 qemu-io-cmds.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
qemu-io-cmds.c +1 -1
index 09750a2..8d93dc6 100644
@@ -357,7 +357,7 @@ static void dump_buffer(const void *buffer, int64_t offset, int64_t len)
     int j;
     const uint8_t *p;
 
-    for (i = 0, p = buffer; i < len; i += 16) {
+    for (i = 0, p = buffer + offset; i < len; i += 16) {
         const uint8_t *s = p;
 
         printf("%08" PRIx64 ":  ", offset + i);
Signature · 1 line
1.8.3.1
#1 lore raw

Hi! Thank you for this patch.

Some notes follow:

Quoted 1 line · lichun

You should write a commit message explaining the problem being fixed by this patch, even if it's very brief.

In the future, try wording subject lines in terms of what the patch "does" instead of what it "did"; i.e.:

"Fix dump_buffer function so that the offset parameter takes effect" is preferable to
"Fixed dump_buffer function parameter offset does not take effect"

Quoted 10 lines
---
 qemu-io-cmds.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
qemu-io-cmds.c +0 -0
index 09750a2..8d93dc6 100644

qemu-io-cmds.c static void dump_buffer(const void *buffer, int64_t offset, int64_t len) · line 363

Quoted 8 lines
qemu-io-cmds.c +1 -1
@@ -357,7 +357,7 @@ static void dump_buffer(const void *buffer, int64_t offset, int64_t len)
     int j;
     const uint8_t *p;
 
-    for (i = 0, p = buffer; i < len; i += 16) {
+    for (i = 0, p = buffer + offset; i < len; i += 16) {
         const uint8_t *s = p;
 
         printf("%08" PRIx64 ":  ", offset + i);

At a glance I am not sure that this patch is correct, it looks to me as if callers are expecting the entire buffer to be dumped and the offset is the offset of *this buffer* relative to some reference point (e.g. the disk being read from.)

Can you point me to examples in which this is obviously wrong?