Input: don't push static constants on stack for %*ph
Subsystems (3)
PATCH 1/1 Input: don't push static constants on stack for %*ph
There is no need to pass constants via stack. The width may be explicitly specified in the format.
--- drivers/input/mouse/hgpk.c | 7 +++---- drivers/input/touchscreen/atmel_mxt_ts.c | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-)
drivers/input/mouse/hgpk.c +3 -4
@@ -333,9 +333,8 @@ static bool hgpk_is_byte_valid(struct psmouse *psmouse, unsigned char *packet) }if (!valid) -psmouse_dbg (psmouse, -"bad data, mode %d (%d) %*ph\n" , - priv->mode, pktcnt,6 , psmouse->packet); +psmouse_dbg (psmouse,"bad data, mode %d (%d) %6ph\n" , + priv->mode, pktcnt, psmouse->packet);return valid; }
@@ -1027,7 +1026,7 @@ static enum hgpk_model_t hgpk_get_model(struct psmouse *psmouse)return -EIO ; } -psmouse_dbg (psmouse,"ID: %*ph\n" ,3 , param); +psmouse_dbg (psmouse,"ID: %3ph\n" , param);/* HGPK signature: 0x67, 0x00, 0x<model> */ if (param[0 ] !=0x67 || param[1 ] !=0x00 )
drivers/input/touchscreen/atmel_mxt_ts.c +2 -2
@@ -331,8 +331,8 @@ static bool mxt_object_writable(unsigned int type)static void mxt_dump_message (struct device *dev,struct mxt_message *message) { -dev_dbg (dev,"reportid: %u\tmessage: %*ph\n" , - message->reportid,7 , message->message); +dev_dbg (dev,"reportid: %u\tmessage: %7ph\n" , + message->reportid, message->message); } static int mxt_check_bootloader(struct i2c_client *client,
Signature · 1 line
1.8.4.rc3
Quoted 2 lines · Andy Shevchenko
There is no need to pass constants via stack. The width may be explicitly specified in the format.
Any comments on this so far?
Quoted 47 lines
Signed-off-by Andy Shevchenko <[email protected]>--- drivers/input/mouse/hgpk.c | 7 +++---- drivers/input/touchscreen/atmel_mxt_ts.c | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-)drivers/input/mouse/hgpk.c +3
-4@@ -333,9 +333,8 @@ static bool hgpk_is_byte_valid(struct psmouse *psmouse, unsigned char *packet) }if (!valid) -psmouse_dbg (psmouse, -"bad data, mode %d (%d) %*ph\n" , - priv->mode, pktcnt,6 , psmouse->packet); +psmouse_dbg (psmouse,"bad data, mode %d (%d) %6ph\n" , + priv->mode, pktcnt, psmouse->packet);return valid; }@@ -1027,7 +1026,7 @@ static enum hgpk_model_t hgpk_get_model(struct psmouse *psmouse)return -EIO ; } -psmouse_dbg (psmouse,"ID: %*ph\n" ,3 , param); +psmouse_dbg (psmouse,"ID: %3ph\n" , param);/* HGPK signature: 0x67, 0x00, 0x<model> */ if (param[0 ] !=0x67 || param[1 ] !=0x00 )drivers/input/touchscreen/atmel_mxt_ts.c +2
-2@@ -331,8 +331,8 @@ static bool mxt_object_writable(unsigned int type)static void mxt_dump_message (struct device *dev,struct mxt_message *message) { -dev_dbg (dev,"reportid: %u\tmessage: %*ph\n" , - message->reportid,7 , message->message); +dev_dbg (dev,"reportid: %u\tmessage: %7ph\n" , + message->reportid, message->message); } static int mxt_check_bootloader(struct i2c_client *client,
Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy
Quoted 3 lines · Andy Shevchenko
There is no need to pass constants via stack. The width may be explicitly
specified in the format.
Dmitry, any comments on this?
Quoted 52 lines
Signed-off-by Andy Shevchenko <[email protected]>---
drivers/input/mouse/hgpk.c | 7 +++----drivers/input/touchscreen/atmel_mxt_ts.c| 4 ++--2 files changed, 5 insertions(+), 6 deletions(-)drivers/input/mouse/hgpk.c +0
-0@@ -333,9 +333,8 @@ static bool hgpk_is_byte_valid(struct psmouse *psmouse, unsigned char *packet) }
if (!valid)drivers/input/mouse/hgpk.c +1
-3-psmouse_dbg (psmouse, - "bad data, mode %d (%d) %*ph\n", - priv->mode, pktcnt, 6, psmouse->packet); + psmouse_dbg(psmouse, "bad data, mode %d (%d)%6ph\n",
drivers/input/mouse/hgpk.c +1
-0+ priv->mode, pktcnt, psmouse->packet);
return valid;
}drivers/input/mouse/hgpk.c +0
-0@@ -1027,7 +1026,7 @@ static enum hgpk_model_t hgpk_get_model(struct psmouse *psmouse) return -EIO; }drivers/input/mouse/hgpk.c +1
-1-psmouse_dbg (psmouse,"ID: %*ph\n" ,3 , param); +psmouse_dbg (psmouse,"ID: %3ph\n" , param);
/* HGPK signature:0x67,0x00, 0x<model> */ if (param[0] !=0x67|| param[1] !=0x00)drivers/input/touchscreen/atmel_mxt_ts.c +2
-2@@ -331,8 +331,8 @@ static bool mxt_object_writable(unsigned int type) static void mxt_dump_message(struct device *dev, struct mxt_message *message) { -dev_dbg (dev,"reportid: %u\tmessage: %*ph\n" , - message->reportid,7 , message->message); +dev_dbg (dev,"reportid: %u\tmessage: %7ph\n" , + message->reportid, message->message); }
static int mxt_check_bootloader(structi2c_client*client,
Signature · 7 lines
Andy Shevchenko <[email protected]> Intel Finland Oy -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Dmitry Torokhov
maintainerQuoted 6 lines · Andy Shevchenko
Quoted 3 lines · Andy Shevchenko
There is no need to pass constants via stack. The width may be explicitly
specified in the format.Dmitry, any comments on this?
My personal preference is to have length as a parameter instead of encoding in format string as it allows using symbolic constants and expressions (even though in these particular cases we use numeric constants). The code is not in critical paths so we can live with extra arguments.
Thanks.
Quoted 58 lines
Quoted 52 lines
Signed-off-by Andy Shevchenko <[email protected]>--- drivers/input/mouse/hgpk.c | 7 +++---- drivers/input/touchscreen/atmel_mxt_ts.c | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-)drivers/input/mouse/hgpk.c +2
-3@@ -333,9 +333,8 @@ static bool hgpk_is_byte_valid(struct psmouse *psmouse, unsigned char *packet) }if (!valid) -psmouse_dbg (psmouse, -"bad data, mode %d (%d) %*ph\n" , - priv->mode, pktcnt,6 , psmouse->packet); + psmouse_dbg(psmouse, "bad data, mode %d (%d) %6ph\n", + priv->mode, pktcnt, psmouse->packet);return valid;}
drivers/input/mouse/hgpk.c +1
-1@@ -1027,7 +1026,7 @@ static enum hgpk_model_t hgpk_get_model(struct psmouse *psmouse)return -EIO ; } -psmouse_dbg (psmouse,"ID: %*ph\n" ,3 , param); +psmouse_dbg (psmouse,"ID: %3ph\n" , param);/* HGPK signature: 0x67, 0x00, 0x<model> */ if (param[0] != 0x67 || param[1] != 0x00)drivers/input/touchscreen/atmel_mxt_ts.c +2
-2@@ -331,8 +331,8 @@ static bool mxt_object_writable(unsigned int type) static void mxt_dump_message(struct device *dev,struct mxt_message *message) { -dev_dbg (dev,"reportid: %u\tmessage: %*ph\n" , - message->reportid,7 , message->message); +dev_dbg (dev,"reportid: %u\tmessage: %7ph\n" , + message->reportid, message->message); }Quoted 1 line
static int mxt_check_bootloader(struct
i2c_client*client,--
Andy Shevchenko <[email protected]> Intel Finland Oy
Signature · 1 line
Dmitry
Quoted 6 lines · Andy Shevchenko
Quoted 3 lines
There is no need to pass constants via stack. The width may be explicitly
specified in the format.Dmitry, any comments on this?
Hi Andy-
Just to weigh in on the atmel_mxt_ts part - it's made moot by:
http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/drivers/input/touchscreen/atmel_mxt_ts.c?id=5f3f9bc2b1f3a09e732df
regards
Nick
Quoted 54 lines
Quoted 53 lines
Signed-off-by Andy Shevchenko <[email protected]>--- drivers/input/mouse/hgpk.c | 7 +++---- drivers/input/touchscreen/atmel_mxt_ts.c | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-)drivers/input/mouse/hgpk.c +2
-3@@ -333,9 +333,8 @@ static bool hgpk_is_byte_valid(struct psmouse *psmouse, unsigned char *packet) }if (!valid) -psmouse_dbg (psmouse, -"bad data, mode %d (%d) %*ph\n" , - priv->mode, pktcnt,6 , psmouse->packet); + psmouse_dbg(psmouse, "bad data, mode %d (%d) %6ph\n", + priv->mode, pktcnt, psmouse->packet);drivers/input/mouse/hgpk.c +1
-1return valid; }@@ -1027,7 +1026,7 @@ static enum hgpk_model_t hgpk_get_model(struct psmouse *psmouse)return -EIO ; } -psmouse_dbg (psmouse,"ID: %*ph\n" ,3 , param); +psmouse_dbg (psmouse,"ID: %3ph\n" , param);/* HGPK signature: 0x67, 0x00, 0x<model> */ drivers/input/mouse/hgpk.c +0
-0if (param[0 ] !=0x67 || param[1 ] !=0x00 )drivers/input/touchscreen/atmel_mxt_ts.c +2
-2@@ -331,8 +331,8 @@ static bool mxt_object_writable(unsigned int type) static void mxt_dump_message(struct device *dev,struct mxt_message *message) { -dev_dbg (dev,"reportid: %u\tmessage: %*ph\n" , - message->reportid,7 , message->message); +dev_dbg (dev,"reportid: %u\tmessage: %7ph\n" , + message->reportid, message->message); }static int mxt_check_bootloader(struct
i2c_client*client,