diff --git a/minissdp.c b/minissdp.c index de41ae7..813a24e 100644 --- a/minissdp.c +++ b/minissdp.c @@ -234,7 +234,7 @@ SendSSDPResponse(int s, struct sockaddr_in sockname, int st_no, (runtime_vars.notify_interval<<1)+10, tmstr, known_service_types[st_no], - (st_no>1?"1":""), + (st_no > 1 ? "1" : ""), uuidvalue, (st_no > 0 ? "::" : ""), (st_no > 0 ? known_service_types[st_no] : ""), diff --git a/scanner.c b/scanner.c index 2e5bcc9..3cef546 100644 --- a/scanner.c +++ b/scanner.c @@ -769,14 +769,14 @@ ScanDirectory(const char *dir, const char *parent, media_types dir_types) if( (type == TYPE_DIR) && (access(full_path, R_OK|X_OK) == 0) ) { char *parent_id; - insert_directory(name, full_path, BROWSEDIR_ID, (parent ? parent:""), i+startID); - xasprintf(&parent_id, "%s$%X", (parent ? parent:""), i+startID); + insert_directory(name, full_path, BROWSEDIR_ID, THISORNUL(parent), i+startID); + xasprintf(&parent_id, "%s$%X", THISORNUL(parent), i+startID); ScanDirectory(full_path, parent_id, dir_types); free(parent_id); } else if( type == TYPE_FILE && (access(full_path, R_OK) == 0) ) { - if( insert_file(name, full_path, (parent ? parent:""), i+startID) == 0 ) + if( insert_file(name, full_path, THISORNUL(parent), i+startID) == 0 ) fileno++; } free(name); diff --git a/upnpglobalvars.h b/upnpglobalvars.h index d21f347..0ff9f2c 100644 --- a/upnpglobalvars.h +++ b/upnpglobalvars.h @@ -73,6 +73,7 @@ #else #define _(string) (string) #endif +#define THISORNUL(s) (s ? s : "") #ifndef PNPX #define PNPX 0 diff --git a/upnpsoap.c b/upnpsoap.c index e0245dc..fe50516 100644 --- a/upnpsoap.c +++ b/upnpsoap.c @@ -1267,7 +1267,7 @@ BrowseContentDirectory(struct upnphttp * h, const char * action) sql = sqlite3_mprintf( SELECT_COLUMNS "from OBJECTS o left join DETAILS d on (d.ID = o.DETAIL_ID)" " where PARENT_ID = '%q' %s limit %d, %d;", - ObjectID, orderBy, StartingIndex, RequestedCount); + ObjectID, THISORNUL(orderBy), StartingIndex, RequestedCount); DPRINTF(E_DEBUG, L_HTTP, "Browse SQL: %s\n", sql); ret = sqlite3_exec(db, sql, callback, (void *) &args, &zErrMsg); } @@ -1787,7 +1787,7 @@ QueryStateVariable(struct upnphttp * h, const char * action) } else { - DPRINTF(E_WARN, L_HTTP, "%s: Unknown: %s\n", action, var_name?var_name:""); + DPRINTF(E_WARN, L_HTTP, "%s: Unknown: %s\n", action, THISORNUL(var_name)); SoapError(h, 404, "Invalid Var"); }