Skip to content

Commit

Permalink
HID: intel-ish-hid: add printf attribute to print_log()
Browse files Browse the repository at this point in the history
Structure ishtp_device contains a logging function, print_log(), which
formats some of its parameters using vsnprintf(). Add a __printf
attribute to this function field (and to ish_event_tracer()) in order to
detect at compile time issues related to the printf-like formatting.

While at it, make format parameter a const pointer as print_log() is not
supposed to modify it.

Signed-off-by: Nicolas Iooss <nicolas.iooss_linux@m4x.org>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
  • Loading branch information
Nicolas Iooss authored and Jiri Kosina committed Jan 2, 2017
1 parent f39fdf2 commit 0aae34f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion drivers/hid/intel-ish-hid/ipc/pci-ish.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ MODULE_DEVICE_TABLE(pci, ish_pci_tbl);
*
* Callback to direct log messages to Linux trace buffers
*/
static void ish_event_tracer(struct ishtp_device *dev, char *format, ...)
static __printf(2, 3)
void ish_event_tracer(struct ishtp_device *dev, const char *format, ...)
{
if (trace_ishtp_dump_enabled()) {
va_list args;
Expand Down
3 changes: 2 additions & 1 deletion drivers/hid/intel-ish-hid/ishtp/ishtp-dev.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,8 @@ struct ishtp_device {
uint64_t ishtp_host_dma_rx_buf_phys;

/* Dump to trace buffers if enabled*/
void (*print_log)(struct ishtp_device *dev, char *format, ...);
__printf(2, 3) void (*print_log)(struct ishtp_device *dev,
const char *format, ...);

/* Debug stats */
unsigned int ipc_rx_cnt;
Expand Down

0 comments on commit 0aae34f

Please sign in to comment.