Add printf attribute to log_err/DPRINTF and fix a few warnings

Modified to not use %z for portability reasons.
This commit is contained in:
Catalin Patulea 2014-03-14 00:36:30 -04:00 committed by Justin Maggard
parent 45cf9208fb
commit 3a57744735
11 changed files with 30 additions and 22 deletions

View File

@ -236,7 +236,8 @@ check_embedded_art(const char *path, const char *image_data, int image_size)
fclose(dstfile); fclose(dstfile);
if( nwritten != image_size ) if( nwritten != image_size )
{ {
DPRINTF(E_WARN, L_METADATA, "Embedded art error: wrote %d/%d bytes\n", nwritten, image_size); DPRINTF(E_WARN, L_METADATA, "Embedded art error: wrote %lu/%d bytes\n",
(unsigned long)nwritten, image_size);
remove(art_path); remove(art_path);
free(art_path); free(art_path);
art_path = NULL; art_path = NULL;

View File

@ -360,7 +360,7 @@ inotify_insert_file(char * name, const char * path)
ts = sql_get_int_field(db, "SELECT TIMESTAMP from DETAILS where PATH = '%q'", path); ts = sql_get_int_field(db, "SELECT TIMESTAMP from DETAILS where PATH = '%q'", path);
if( !ts && is_playlist(path) && (sql_get_int_field(db, "SELECT ID from PLAYLISTS where PATH = '%q'", path) > 0) ) if( !ts && is_playlist(path) && (sql_get_int_field(db, "SELECT ID from PLAYLISTS where PATH = '%q'", path) > 0) )
{ {
DPRINTF(E_DEBUG, L_INOTIFY, "Re-reading modified playlist.\n", path); DPRINTF(E_DEBUG, L_INOTIFY, "Re-reading modified playlist (%s).\n", path);
inotify_remove_file(path); inotify_remove_file(path);
next_pl_fill = 1; next_pl_fill = 1;
} }

3
log.h
View File

@ -46,7 +46,8 @@ enum _log_facility
extern int log_level[L_MAX]; extern int log_level[L_MAX];
extern int log_init(const char *fname, const char *debug); extern int log_init(const char *fname, const char *debug);
extern void log_close(void); extern void log_close(void);
extern void log_err(int level, enum _log_facility facility, char *fname, int lineno, char *fmt, ...); extern void log_err(int level, enum _log_facility facility, char *fname, int lineno, char *fmt, ...)
__attribute__((__format__ (__printf__, 5, 6)));
#define DPRINTF(level, facility, fmt, arg...) do { log_err(level, facility, __FILE__, __LINE__, fmt, ##arg); } while (0) #define DPRINTF(level, facility, fmt, arg...) do { log_err(level, facility, __FILE__, __LINE__, fmt, ##arg); } while (0)

View File

@ -357,7 +357,8 @@ rescan:
else if (ret == 2) else if (ret == 2)
DPRINTF(E_WARN, L_GENERAL, "Removed media_dir detected; rescanning...\n"); DPRINTF(E_WARN, L_GENERAL, "Removed media_dir detected; rescanning...\n");
else else
DPRINTF(E_WARN, L_GENERAL, "Database version mismatch; need to recreate...\n"); DPRINTF(E_WARN, L_GENERAL, "Database version mismatch (%d=>%d); need to recreate...\n",
ret, DB_VERSION);
sqlite3_close(db); sqlite3_close(db);
snprintf(cmd, sizeof(cmd), "rm -rf %s/files.db %s/art_cache", db_path, db_path); snprintf(cmd, sizeof(cmd), "rm -rf %s/files.db %s/art_cache", db_path, db_path);
@ -424,7 +425,7 @@ writepidfile(const char *fname, int pid, uid_t uid)
if (uid > 0) if (uid > 0)
{ {
if (chown(dir, uid, -1) != 0) if (chown(dir, uid, -1) != 0)
DPRINTF(E_WARN, L_GENERAL, "Unable to change pidfile ownership: %s\n", DPRINTF(E_WARN, L_GENERAL, "Unable to change pidfile %s ownership: %s\n",
dir, strerror(errno)); dir, strerror(errno));
} }
} }
@ -440,14 +441,14 @@ writepidfile(const char *fname, int pid, uid_t uid)
if (fprintf(pidfile, "%d\n", pid) <= 0) if (fprintf(pidfile, "%d\n", pid) <= 0)
{ {
DPRINTF(E_ERROR, L_GENERAL, DPRINTF(E_ERROR, L_GENERAL,
"Unable to write to pidfile %s: %s\n", fname); "Unable to write to pidfile %s: %s\n", fname, strerror(errno));
ret = -1; ret = -1;
} }
if (uid > 0) if (uid > 0)
{ {
if (fchown(fileno(pidfile), uid, -1) != 0) if (fchown(fileno(pidfile), uid, -1) != 0)
DPRINTF(E_WARN, L_GENERAL, "Unable to change pidfile ownership: %s\n", DPRINTF(E_WARN, L_GENERAL, "Unable to change pidfile %s ownership: %s\n",
pidfile, strerror(errno)); fname, strerror(errno));
} }
fclose(pidfile); fclose(pidfile);

View File

@ -861,7 +861,7 @@ start_scanner()
fill_playlists(); fill_playlists();
} }
DPRINTF(E_DEBUG, L_SCANNER, "Initial file scan completed\n", DB_VERSION); DPRINTF(E_DEBUG, L_SCANNER, "Initial file scan completed\n");
//JM: Set up a db version number, so we know if we need to rebuild due to a new structure. //JM: Set up a db version number, so we know if we need to rebuild due to a new structure.
sql_exec(db, "pragma user_version = %d;", DB_VERSION); sql_exec(db, "pragma user_version = %d;", DB_VERSION);
} }

2
sql.c
View File

@ -214,7 +214,7 @@ db_upgrade(sqlite3 *db)
if (db_vers < 1) if (db_vers < 1)
return -1; return -1;
if (db_vers < 9) if (db_vers < 9)
return 9; return db_vers;
sql_exec(db, "PRAGMA user_version = %d", DB_VERSION); sql_exec(db, "PRAGMA user_version = %d", DB_VERSION);
return 0; return 0;

View File

@ -567,7 +567,8 @@ _get_asffileinfo(char *file, struct song_metadata *psong)
if(pos + tmp.Size > hdr.Size) if(pos + tmp.Size > hdr.Size)
{ {
DPRINTF(E_ERROR, L_SCANNER, "Size overrun reading header object %I64x\n", tmp.Size); DPRINTF(E_ERROR, L_SCANNER, "Size overrun reading header object %llu\n",
(unsigned long long)tmp.Size);
break; break;
} }

View File

@ -190,7 +190,12 @@ vc_scan(struct song_metadata *psong, const char *comment, const size_t length)
{ {
if( strncasecmp(comment, "LYRICS=", 7) != 0 ) if( strncasecmp(comment, "LYRICS=", 7) != 0 )
{ {
DPRINTF(E_WARN, L_SCANNER, "Vorbis %.*s too long [%s]\n", (index(comment, '=')-comment), comment, psong->path); const char *eq = strchr(comment, '=');
int len = 8;
if (eq)
len = eq - comment;
DPRINTF(E_WARN, L_SCANNER, "Vorbis %.*s too long [%s]\n",
len, comment, psong->path);
} }
return; return;
} }

View File

@ -179,9 +179,6 @@ _ogg_vorbis_process(ogg_stream_processor *stream, ogg_page *page,
ogg_int64_t gp = ogg_page_granulepos(page); ogg_int64_t gp = ogg_page_granulepos(page);
if(gp > 0) if(gp > 0)
{ {
if(gp < inf->lastgranulepos)
DPRINTF(E_WARN, L_SCANNER, "granulepos in stream %d decreases from %lld to %lld",
stream->num, inf->lastgranulepos, gp);
inf->lastgranulepos = gp; inf->lastgranulepos = gp;
} }
else else
@ -402,7 +399,8 @@ _ogg_get_next_page(FILE *f, ogg_sync_state *sync, ogg_page *page,
while((ret = ogg_sync_pageout(sync, page)) <= 0) while((ret = ogg_sync_pageout(sync, page)) <= 0)
{ {
if(ret < 0) if(ret < 0)
DPRINTF(E_WARN, L_SCANNER, "Hole in data found at approximate offset %lld bytes. Corrupted ogg.\n", *written); DPRINTF(E_WARN, L_SCANNER, "Hole in data found at approximate offset %lld bytes. Corrupted ogg.\n",
(long long)*written);
buffer = ogg_sync_buffer(sync, 4500); // chunk=4500 buffer = ogg_sync_buffer(sync, 4500); // chunk=4500
bytes = fread(buffer, 1, 4500, f); bytes = fread(buffer, 1, 4500, f);

View File

@ -244,7 +244,8 @@ ParseHttpHeaders(struct upnphttp * h)
h->req_RangeStart = strtoll(p+6, &colon, 10); h->req_RangeStart = strtoll(p+6, &colon, 10);
h->req_RangeEnd = colon ? atoll(colon+1) : 0; h->req_RangeEnd = colon ? atoll(colon+1) : 0;
DPRINTF(E_DEBUG, L_HTTP, "Range Start-End: %lld - %lld\n", DPRINTF(E_DEBUG, L_HTTP, "Range Start-End: %lld - %lld\n",
h->req_RangeStart, h->req_RangeEnd?h->req_RangeEnd:-1); (long long)h->req_RangeStart,
h->req_RangeEnd ? (long long)h->req_RangeEnd : -1);
} }
} }
else if(strncasecmp(line, "Host", 4)==0) else if(strncasecmp(line, "Host", 4)==0)
@ -1048,7 +1049,7 @@ Process_upnphttp(struct upnphttp * h)
} }
else else
{ {
size_t new_req_buflen; int new_req_buflen;
const char * endheaders; const char * endheaders;
/* if 1st arg of realloc() is null, /* if 1st arg of realloc() is null,
* realloc behaves the same as malloc() */ * realloc behaves the same as malloc() */
@ -1823,7 +1824,7 @@ SendResp_dlnafile(struct upnphttp *h, char *object)
ret = sql_get_table(db, buf, &result, &rows, NULL); ret = sql_get_table(db, buf, &result, &rows, NULL);
if( (ret != SQLITE_OK) ) if( (ret != SQLITE_OK) )
{ {
DPRINTF(E_ERROR, L_HTTP, "Didn't find valid file for %lld!\n", id); DPRINTF(E_ERROR, L_HTTP, "Didn't find valid file for %lld!\n", (long long)id);
Send500(h); Send500(h);
return; return;
} }
@ -1876,7 +1877,7 @@ SendResp_dlnafile(struct upnphttp *h, char *object)
} }
#endif #endif
DPRINTF(E_INFO, L_HTTP, "Serving DetailID: %lld [%s]\n", id, last_file.path); DPRINTF(E_INFO, L_HTTP, "Serving DetailID: %lld [%s]\n", (long long)id, last_file.path);
if( h->reqflags & FLAG_XFERSTREAMING ) if( h->reqflags & FLAG_XFERSTREAMING )
{ {

View File

@ -710,8 +710,8 @@ callback(void *args, int argc, char **argv, char **azColName)
if( str->data ) if( str->data )
{ {
str->size += DEFAULT_RESP_SIZE; str->size += DEFAULT_RESP_SIZE;
DPRINTF(E_DEBUG, L_HTTP, "UPnP SOAP response enlarged to %d. [%d results so far]\n", DPRINTF(E_DEBUG, L_HTTP, "UPnP SOAP response enlarged to %lu. [%d results so far]\n",
str->size, passed_args->returned); (unsigned long)str->size, passed_args->returned);
} }
else else
{ {