Skip to contentSkip to conversation

soc: qcom: cmd-db: Cast sizeof() to int to silence field width warning

PATCH In review Stephen Boyd 2 participants 3 messages Apr 15, 2020 – Apr 17, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 soc: qcom: cmd-db: Cast sizeof() to int to silence field width warning

We pass the result of sizeof() here to tell the printk format specifier how many bytes to print. That expects an int though and sizeof() isn't that type. Cast to int to silence this warning:

drivers/soc/qcom/cmd-db.c: In function 'cmd_db_debugfs_dump':
drivers/soc/qcom/cmd-db.c:281:30: warning: field width specifier '*' expects argument of type 'int', but argument 4 has type 'long unsigned int' [-Wformat=]

---
 drivers/soc/qcom/cmd-db.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/qcom/cmd-db.c +1 -1
index 6c308f92a13c..6b5c440c9dc3 100644
@@ -280,7 +280,7 @@ static int cmd_db_debugfs_dump(struct seq_file *seq, void *p)
 		ent = rsc_to_entry_header(rsc);
 		for (j = 0; j < le16_to_cpu(rsc->cnt); j++, ent++) {
 			seq_printf(seq, "0x%08x: %*pEp", le32_to_cpu(ent->addr),
-				   sizeof(ent->id), ent->id);
+				   (int)sizeof(ent->id), ent->id);
 
 			len = le16_to_cpu(ent->len);
 			if (len) {
Signature · 1 line
Sent by a computer, using git, on the internet
#1 lore raw

Quoting Stephen Boyd (2020-04-14 23:20:33)

Quoted 9 lines

We pass the result of sizeof() here to tell the printk format specifier how many bytes to print. That expects an int though and sizeof() isn't that type. Cast to int to silence this warning:

drivers/soc/qcom/cmd-db.c: In function 'cmd_db_debugfs_dump':
drivers/soc/qcom/cmd-db.c:281:30: warning: field width specifier '*' expects argument of type 'int', but argument 4 has type 'long unsigned int' [-Wformat=]

Also

Fixes d6815c5c43d4 ("soc: qcom: cmd-db: Add debugfs dumping file")
Quoted 17 lines
---
 drivers/soc/qcom/cmd-db.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/qcom/cmd-db.c +1 -1
index 6c308f92a13c..6b5c440c9dc3 100644
@@ -280,7 +280,7 @@ static int cmd_db_debugfs_dump(struct seq_file *seq, void *p)
                ent = rsc_to_entry_header(rsc);
                for (j = 0; j < le16_to_cpu(rsc->cnt); j++, ent++) {
                        seq_printf(seq, "0x%08x: %*pEp", le32_to_cpu(ent->addr),
-                                  sizeof(ent->id), ent->id);
+                                  (int)sizeof(ent->id), ent->id);
 
                        len = le16_to_cpu(ent->len);
                        if (len) {
Reviewed-by on v1 1/1
#2 lore raw
In reply to Stephen Boyd
Quoted 9 lines · Stephen Boyd

We pass the result of sizeof() here to tell the printk format specifier how many bytes to print. That expects an int though and sizeof() isn't that type. Cast to int to silence this warning:

drivers/soc/qcom/cmd-db.c: In function 'cmd_db_debugfs_dump':
drivers/soc/qcom/cmd-db.c:281:30: warning: field width specifier '*' expects argument of type 'int', but argument 4 has type 'long unsigned int' [-Wformat=]

Quoted 17 lines
---
 drivers/soc/qcom/cmd-db.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/qcom/cmd-db.c +1 -1
index 6c308f92a13c..6b5c440c9dc3 100644
@@ -280,7 +280,7 @@ static int cmd_db_debugfs_dump(struct seq_file *seq, void *p)
 		ent = rsc_to_entry_header(rsc);
 		for (j = 0; j < le16_to_cpu(rsc->cnt); j++, ent++) {
 			seq_printf(seq, "0x%08x: %*pEp", le32_to_cpu(ent->addr),
-				   sizeof(ent->id), ent->id);
+				   (int)sizeof(ent->id), ent->id);
 
 			len = le16_to_cpu(ent->len);
 			if (len) {