Skip to contentSkip to conversation

cmd: blk: Use LBAFD in the common block command

PATCH New Bin Meng 2 participants 3 messages Aug 22, 2017

lore
Share & tools
lore

Bin Meng

author
#0 lore raw

PATCH 1/1 cmd: blk: Use LBAFD in the common block command

There are already two macros LBAF and LBAFU to aid formatted print with lbaint_t variables. Now let's add another one LBAFD and use it in the common block command codes.

---

 cmd/blk_common.c | 10 ++++------
 include/blk.h    |  1 +
 2 files changed, 5 insertions(+), 6 deletions(-)
cmd/blk_common.c +4 -6
index 86c75e7..2626eef 100644
@@ -68,9 +68,8 @@ int blk_common_cmd(int argc, char * const argv[], enum if_type if_type,
 			ulong cnt = simple_strtoul(argv[4], NULL, 16);
 			ulong n;
 
-			printf("\n%s read: device %d block # %lld, count %ld ... ",
-			       if_name, *cur_devnump, (unsigned long long)blk,
-			       cnt);
+			printf("\n%s read: device %d block # "LBAFD", count %ld ... ",
+			       if_name, *cur_devnump, blk, cnt);
 
 			n = blk_read_devnum(if_type, *cur_devnump, blk, cnt,
 					    (ulong *)addr);
@@ -84,9 +83,8 @@ int blk_common_cmd(int argc, char * const argv[], enum if_type if_type,
 			ulong cnt = simple_strtoul(argv[4], NULL, 16);
 			ulong n;
 
-			printf("\n%s write: device %d block # %lld, count %ld ... ",
-			       if_name, *cur_devnump, (unsigned long long)blk,
-			       cnt);
+			printf("\n%s write: device %d block # "LBAFD", count %ld ... ",
+			       if_name, *cur_devnump, blk, cnt);
 
 			n = blk_write_devnum(if_type, *cur_devnump, blk, cnt,
 					     (ulong *)addr);
include/blk.h +1 -0
index a106f9c..9a3e6106 100644
@@ -17,6 +17,7 @@ typedef ulong lbaint_t;
 #endif
 #define LBAF "%" LBAFlength "x"
 #define LBAFU "%" LBAFlength "u"
+#define LBAFD "%" LBAFlength "d"
 
 /* Interface types: */
 enum if_type {
Signature · 1 line
2.9.2
#1 lore raw

PATCH 1/1 cmd: blk: Use LBAFD in the common block command

Hi,

Quoted 30 lines · On Mon, 21 Aug 2017 21:53:41 -0700 Bin Meng wrote:

There are already two macros LBAF and LBAFU to aid formatted print with lbaint_t variables. Now let's add another one LBAFD and use it in the common block command codes.

---

 cmd/blk_common.c | 10 ++++------
 include/blk.h    |  1 +
 2 files changed, 5 insertions(+), 6 deletions(-)
cmd/blk_common.c +2 -3
index 86c75e7..2626eef 100644
@@ -68,9 +68,8 @@ int blk_common_cmd(int argc, char * const argv[], enum if_type if_type,
 			ulong cnt = simple_strtoul(argv[4], NULL, 16);
 			ulong n;
 
-			printf("\n%s read: device %d block # %lld, count %ld ... ",
-			       if_name, *cur_devnump, (unsigned long long)blk,
-			       cnt);
+			printf("\n%s read: device %d block # "LBAFD", count %ld ... ",
+			       if_name, *cur_devnump, blk, cnt);
 
 			n = blk_read_devnum(if_type, *cur_devnump, blk, cnt,
 					    (ulong *)addr);
@@ -84,9 +83,8 @@ int blk_common_cmd(int argc, char * const argv[], enum if_type if_type,
 			ulong cnt = simple_strtoul(argv[4], NULL, 16);

cmd/blk_common.c int blk_common_cmd(int argc, char * const argv[], enum if_type if_type, · line 90

Quoted 10 lines
cmd/blk_common.c +2 -3
 			ulong n;
 
-			printf("\n%s write: device %d block # %lld, count %ld ... ",
-			       if_name, *cur_devnump, (unsigned long long)blk,
-			       cnt);
+			printf("\n%s write: device %d block # "LBAFD", count %ld ... ",
+			       if_name, *cur_devnump, blk, cnt);
 
 			n = blk_write_devnum(if_type, *cur_devnump, blk, cnt,
 					     (ulong *)addr);

Are there devices that have valid negative block numbers? Otherwise using LBAFU would be fine here.

Lothar Waßmann

author
#2 lore raw

PATCH 1/1 cmd: blk: Use LBAFD in the common block command

Hi Lothar,

Quoted 40 lines · Lothar Waßmann

Hi,

Quoted 37 lines · On Mon, 21 Aug 2017 21:53:41 -0700 Bin Meng wrote:

There are already two macros LBAF and LBAFU to aid formatted print with lbaint_t variables. Now let's add another one LBAFD and use it in the common block command codes.

---

 cmd/blk_common.c | 10 ++++------
 include/blk.h    |  1 +
 2 files changed, 5 insertions(+), 6 deletions(-)
cmd/blk_common.c +4 -6
index 86c75e7..2626eef 100644
@@ -68,9 +68,8 @@ int blk_common_cmd(int argc, char * const argv[], enum if_type if_type,
                      ulong cnt = simple_strtoul(argv[4], NULL, 16);
                      ulong n;
 
-                     printf("\n%s read: device %d block # %lld, count %ld ... ",
-                            if_name, *cur_devnump, (unsigned long long)blk,
-                            cnt);
+                     printf("\n%s read: device %d block # "LBAFD", count %ld ... ",
+                            if_name, *cur_devnump, blk, cnt);
 
                      n = blk_read_devnum(if_type, *cur_devnump, blk, cnt,
                                          (ulong *)addr);
@@ -84,9 +83,8 @@ int blk_common_cmd(int argc, char * const argv[], enum if_type if_type,
                      ulong cnt = simple_strtoul(argv[4], NULL, 16);
                      ulong n;
 
-                     printf("\n%s write: device %d block # %lld, count %ld ... ",
-                            if_name, *cur_devnump, (unsigned long long)blk,
-                            cnt);
+                     printf("\n%s write: device %d block # "LBAFD", count %ld ... ",
+                            if_name, *cur_devnump, blk, cnt);
 
Quoted 5 lines

cmd/blk_common.c int blk_common_cmd(int argc, char * const argv[], enum if_type if_type, · line 90

Quoted 3 lines
cmd/blk_common.c +0 -0
                      n = blk_write_devnum(if_type, *cur_devnump, blk, cnt,
                                           (ulong *)addr);

Are there devices that have valid negative block numbers? Otherwise using LBAFU would be fine here.

Makes sense. Will do in v2.

Regards,
Bin