Skip to contentSkip to conversation

Fix sparse warnings for I2C_BOARD_INFO()

PATCH In review Ben Hutchings 2 participants 2 messages Apr 8, 2009

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

PATCH 1/1 Fix sparse warnings for I2C_BOARD_INFO()

Since the first argument to I2C_BOARD_INFO() must be a string constant, there is no need to parenthesise it, and adding parentheses results in an invalid initialiser for char[]. gcc obviously accepts this syntax as an extension, but sparse complains, e.g.:

drivers/net/sfc/boards.c:173:2: warning: array initialized from parenthesized string constant

Therefore, remove the parentheses.

---
 i2c.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

---

include/linux/i2c.h +1 -1
index c86c3b0..f352a0a 100644
@@ -274,7 +274,7 @@ struct i2c_board_info {
  * are provided using conventional syntax.
  */
 #define I2C_BOARD_INFO(dev_type, dev_addr) \
-	.type = (dev_type), .addr = (dev_addr)
+	.type = dev_type, .addr = (dev_addr)
 
 
 /* Add-on boards should register/unregister their devices; e.g. a board
Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
#1 lore raw

Hi Ben,

Quoted 20 lines · Ben Hutchings

Since the first argument to I2C_BOARD_INFO() must be a string constant, there is no need to parenthesise it, and adding parentheses results in an invalid initialiser for char[]. gcc obviously accepts this syntax as an extension, but sparse complains, e.g.:

drivers/net/sfc/boards.c:173:2: warning: array initialized from parenthesized string constant

Therefore, remove the parentheses.

---
 i2c.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

---

include/linux/i2c.h +0 -0
index c86c3b0..f352a0a 100644

include/linux/i2c.h struct i2c_board_info { · line 280

Quoted 8 lines
include/linux/i2c.h +1 -1
@@ -274,7 +274,7 @@ struct i2c_board_info {
  * are provided using conventional syntax.
  */
 #define I2C_BOARD_INFO(dev_type, dev_addr) \
-	.type = (dev_type), .addr = (dev_addr)
+	.type = dev_type, .addr = (dev_addr)
 
 
 /* Add-on boards should register/unregister their devices; e.g. a board

Good catch! Applied, thanks.

Signature · 1 line
Jean Delvare