From 45cf9208fb4bdfacdbaa8015af93c28b12702f27 Mon Sep 17 00:00:00 2001 From: Justin Maggard Date: Thu, 10 Apr 2014 18:18:28 -0700 Subject: [PATCH] Declare printf-like attributes for strcatf() and xasprintf() Declare printf-like attributes for strcatf() and xasprintf(), and clean up errors found by the compile after doing so. --- tivo_commands.c | 2 +- upnphttp.c | 4 ++-- utils.h | 6 ++++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/tivo_commands.c b/tivo_commands.c index 5d3d253..2af72f9 100644 --- a/tivo_commands.c +++ b/tivo_commands.c @@ -308,7 +308,7 @@ SendItemDetails(struct upnphttp *h, int64_t item) args.requested = 1; xasprintf(&sql, SELECT_COLUMNS "from OBJECTS o left join DETAILS d on (d.ID = o.DETAIL_ID)" - " where o.DETAIL_ID = %lld group by o.DETAIL_ID", item); + " where o.DETAIL_ID = %lld group by o.DETAIL_ID", (long long)item); DPRINTF(E_DEBUG, L_TIVO, "%s\n", sql); ret = sqlite3_exec(db, sql, callback, (void *) &args, &zErrMsg); free(sql); diff --git a/upnphttp.c b/upnphttp.c index b5db9a1..d394309 100644 --- a/upnphttp.c +++ b/upnphttp.c @@ -1984,9 +1984,9 @@ SendResp_dlnafile(struct upnphttp *h, char *object) if( h->reqflags & FLAG_CAPTION ) { - if( sql_get_int_field(db, "SELECT ID from CAPTIONS where ID = '%lld'", id) > 0 ) + if( sql_get_int_field(db, "SELECT ID from CAPTIONS where ID = '%lld'", (long long)id) > 0 ) strcatf(&str, "CaptionInfo.sec: http://%s:%d/Captions/%lld.srt\r\n", - lan_addr[h->iface].str, runtime_vars.port, id); + lan_addr[h->iface].str, runtime_vars.port, (long long)id); } strftime(date, 30,"%a, %d %b %Y %H:%M:%S GMT" , gmtime(&curtime)); diff --git a/utils.h b/utils.h index 6457188..9fa5fb8 100644 --- a/utils.h +++ b/utils.h @@ -31,7 +31,9 @@ /* String functions */ /* We really want this one inlined, since it has a major performance impact */ -static inline int strcatf(struct string_s *str, const char *fmt, ...) +static inline int +__attribute__((__format__ (__printf__, 2, 3))) +strcatf(struct string_s *str, const char *fmt, ...) { int ret; int size; @@ -53,7 +55,7 @@ static inline void strncpyt(char *dst, const char *src, size_t len) strncpy(dst, src, len); dst[len-1] = '\0'; } -int xasprintf(char **strp, char *fmt, ...); +int xasprintf(char **strp, char *fmt, ...) __attribute__((__format__ (__printf__, 2, 3))); int ends_with(const char * haystack, const char * needle); char *trim(char *str); char *strstrc(const char *s, const char *p, const char t);