Thread (4 messages) 4 messages, 3 authors, 2021-09-27

Re: [PATCH] led-class-flash: fix -Wrestrict warning

From: Pavel Machek <hidden>
Date: 2021-09-27 10:31:41
Also in: linux-leds, lkml

Hi!
quoted hunk ↗ jump to hunk
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/leds/led-class-flash.c | 2 +-
 drivers/thunderbolt/xdomain.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/leds/led-class-flash.c b/drivers/leds/led-class-flash.c
index 185e17055317..6fe9d700dfef 100644
--- a/drivers/leds/led-class-flash.c
+++ b/drivers/leds/led-class-flash.c
@@ -207,7 +207,7 @@ static ssize_t flash_fault_show(struct device *dev,
 		mask <<= 1;
 	}
 
-	return sprintf(buf, "%s\n", buf);
+	return strlen(strcat(buf, "\n"));
 }
 static DEVICE_ATTR_RO(flash_fault);
That's not just a warning. .. the code is crazy. I'll take it if you
split it from the thunderbolt change.

Best regards,
								Pavel
quoted hunk ↗ jump to hunk
diff --git a/drivers/thunderbolt/xdomain.c b/drivers/thunderbolt/xdomain.c
index d66ea4d616fd..eff32499610f 100644
--- a/drivers/thunderbolt/xdomain.c
+++ b/drivers/thunderbolt/xdomain.c
@@ -730,7 +730,7 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
 
 	/* Full buffer size except new line and null termination */
 	get_modalias(svc, buf, PAGE_SIZE - 2);
-	return sprintf(buf, "%s\n", buf);
+	return strlen(strcat(buf, "\n"));
 }
 static DEVICE_ATTR_RO(modalias);
 
-- 
2.29.2
-- 
http://www.livejournal.com/~pavelmachek

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help