From 741d4f7e99bec280a88ac680de48bc930e30adcf Mon Sep 17 00:00:00 2001 From: Justin Maggard Date: Fri, 1 Jul 2011 18:18:33 +0000 Subject: [PATCH] * Fix up some minor quibbles from cppcheck. --- minidlna.conf | 2 +- tagutils/tagutils-ogg.c | 1 + tivo_beacon.c | 17 +++--- tivo_commands.c | 117 ++++++++++++++++++++-------------------- 4 files changed, 71 insertions(+), 66 deletions(-) diff --git a/minidlna.conf b/minidlna.conf index 9849f59..da55668 100644 --- a/minidlna.conf +++ b/minidlna.conf @@ -1,7 +1,7 @@ # port for HTTP (descriptions, SOAP, media transfer) traffic port=8200 -# network interface to bind to (this is the only interface that will serve files) +# network interfaces to serve, comma delimited #network_interface=eth0 # set this to the directory you want scanned. diff --git a/tagutils/tagutils-ogg.c b/tagutils/tagutils-ogg.c index ed9de40..8a3396d 100644 --- a/tagutils/tagutils-ogg.c +++ b/tagutils/tagutils-ogg.c @@ -450,6 +450,7 @@ _get_oggfileinfo(char *filename, struct song_metadata *psong) { DPRINTF(E_FATAL, L_SCANNER, "Could not find a processor for stream, bailing\n"); _ogg_free_stream_set(processors); + fclose(file); return -1; } diff --git a/tivo_beacon.c b/tivo_beacon.c index 5f11132..80632d8 100644 --- a/tivo_beacon.c +++ b/tivo_beacon.c @@ -153,13 +153,12 @@ sendBeaconMessage(int fd, struct sockaddr_in * client, int len, int broadcast) int mesg_len; mesg_len = asprintf(&mesg, "TiVoConnect=1\n" - "swversion=%s\n" + "swversion=1.0\n" "method=%s\n" "identity=%s\n" "machine=%s\n" "platform=pc/minidlna\n" "services=TiVoMediaServer:%d/http\n", - "1.0", broadcast ? "broadcast" : "connected", uuidvalue, friendly_name, runtime_vars.port); DPRINTF(E_DEBUG, L_TIVO, "Sending TiVo beacon to %s\n", inet_ntoa(client->sin_addr)); @@ -209,10 +208,6 @@ rcvBeaconMessage(char * beacon) if( tivoConnect == NULL ) return 0; - /* It's pointless to respond to our own beacon */ - if( strcmp(identity, uuidvalue) == 0) - return 0; - #ifdef DEBUG static struct aBeacon* topBeacon = NULL; struct aBeacon * b; @@ -273,8 +268,18 @@ rcvBeaconMessage(char * beacon) lastSummary = current; } #endif + /* It's pointless to respond to a non-TiVo beacon. */ + if( strncmp(platform, "tcd/", 4) != 0 ) + return 0; + if( strcasecmp(method, "broadcast") == 0 ) + { + DPRINTF(E_DEBUG, L_TIVO, "Received new beacon: machine(%s) platform(%s) services(%s)\n", + machine ? machine : "-", + platform ? platform : "-", + services ? services : "-" ); return 1; + } return 0; } diff --git a/tivo_commands.c b/tivo_commands.c index c70d040..f60aa88 100644 --- a/tivo_commands.c +++ b/tivo_commands.c @@ -112,7 +112,6 @@ int callback(void *args, int argc, char **argv, char **azColName) char *id = argv[0], *class = argv[1], *detailID = argv[2], *size = argv[3], *title = argv[4], *duration = argv[5], *bitrate = argv[6], *sampleFrequency = argv[7], *artist = argv[8], *album = argv[9], *genre = argv[10], *comment = argv[11], *date = argv[12], *resolution = argv[13], *mime = argv[14], *path = argv[15]; - int ret = 0; struct string_s *str = passed_args->str; if( strncmp(class, "item", 4) == 0 ) @@ -122,34 +121,34 @@ int callback(void *args, int argc, char **argv, char **azColName) if( strncmp(mime, "audio", 5) == 0 ) { flags |= FLAG_NO_PARAMS; - ret = strcatf(str, "
" - "audio/*" - "%s" - "%s" - "%s", mime, size, title); + strcatf(str, "
" + "audio/*" + "%s" + "%s" + "%s", mime, size, title); if( date ) { - ret = strcatf(str, "%.*s", 4, date); + strcatf(str, "%.*s", 4, date); } } else if( strcmp(mime, "image/jpeg") == 0 ) { flags |= FLAG_SEND_RESIZED; - ret = strcatf(str, "
" - "image/*" - "image/jpeg" - "%s", size); + strcatf(str, "
" + "image/*" + "image/jpeg" + "%s", size); if( date ) { struct tm tm; memset(&tm, 0, sizeof(tm)); tm.tm_isdst = -1; // Have libc figure out if DST is in effect or not strptime(date, "%Y-%m-%dT%H:%M:%S", &tm); - ret = strcatf(str, "0x%X", (unsigned int)mktime(&tm)); + strcatf(str, "0x%X", (unsigned int)mktime(&tm)); } if( comment ) { - ret = strcatf(str, "%s", comment); + strcatf(str, "%s", comment); } } else if( strncmp(mime, "video", 5) == 0 ) @@ -157,20 +156,20 @@ int callback(void *args, int argc, char **argv, char **azColName) char *episode; flags |= FLAG_NO_PARAMS; flags |= FLAG_VIDEO; - ret = strcatf(str, "
" - "video/x-tivo-mpeg" - "%s" - "%s", mime, size); + strcatf(str, "
" + "video/x-tivo-mpeg" + "%s" + "%s", mime, size); episode = strstr(title, " - "); if( episode ) { - ret = strcatf(str, "%.*s" - "%s", - (int)(episode-title), title, episode+3); + strcatf(str, "%.*s" + "%s", + (int)(episode-title), title, episode+3); } else { - ret = strcatf(str, "%s", title); + strcatf(str, "%s", title); } if( date ) { @@ -178,64 +177,64 @@ int callback(void *args, int argc, char **argv, char **azColName) memset(&tm, 0, sizeof(tm)); tm.tm_isdst = -1; // Have libc figure out if DST is in effect or not strptime(date, "%Y-%m-%dT%H:%M:%S", &tm); - ret = strcatf(str, "0x%X", (unsigned int)mktime(&tm)); + strcatf(str, "0x%X", (unsigned int)mktime(&tm)); } if( comment ) { - ret = strcatf(str, "%s", comment); + strcatf(str, "%s", comment); } } else { return 0; } - ret = strcatf(str, "%s", unescape_tag(title)); + strcatf(str, "%s", unescape_tag(title)); if( artist ) { - ret = strcatf(str, "%s", unescape_tag(artist)); + strcatf(str, "%s", unescape_tag(artist)); } if( album ) { - ret = strcatf(str, "%s", unescape_tag(album)); + strcatf(str, "%s", unescape_tag(album)); } if( genre ) { - ret = strcatf(str, "%s", unescape_tag(genre)); + strcatf(str, "%s", unescape_tag(genre)); } if( resolution ) { char *width = strsep(&resolution, "x"); - ret = strcatf(str, "%s" + strcatf(str, "%s" "%s", width, resolution); } if( duration ) { - ret = strcatf(str, "%d", + strcatf(str, "%d", atoi(strrchr(duration, '.')+1) + (1000*atoi(strrchr(duration, ':')+1)) + (60000*atoi(strrchr(duration, ':')-2)) + (3600000*atoi(duration))); } if( bitrate ) { - ret = strcatf(str, "%s", bitrate); + strcatf(str, "%s", bitrate); } if( sampleFrequency ) { - ret = strcatf(str, "%s", sampleFrequency); + strcatf(str, "%s", sampleFrequency); } - ret = strcatf(str, "
" - "%s" - "/%s/%s.dat%s", - mime, - (flags & FLAG_SEND_RESIZED)?"Resized":"MediaItems", detailID, - (flags & FLAG_NO_PARAMS)?"No":""); + strcatf(str, "
" + "%s" + "/%s/%s.dat%s", + mime, + (flags & FLAG_SEND_RESIZED)?"Resized":"MediaItems", detailID, + (flags & FLAG_NO_PARAMS)?"No":""); if( flags & FLAG_VIDEO ) { char *esc_name = escape_tag(basename(path), 1); - ret = strcatf(str, "" - "video/*" - "urn:tivo:image:save-until-i-delete-recording" - "" - "Videos" - "%s ", esc_name); + strcatf(str, "" + "video/*" + "urn:tivo:image:save-until-i-delete-recording" + "" + "Videos" + "%s ", esc_name); free(esc_name); } else { - ret = strcatf(str, ""); + strcatf(str, ""); } } else if( strncmp(class, "container", 9) == 0 ) @@ -249,22 +248,22 @@ int callback(void *args, int argc, char **argv, char **azColName) " (MIME in ('image/jpeg', 'audio/mpeg', 'video/mpeg', 'video/x-tivo-mpeg')" " or CLASS glob 'container*')", id); #endif - ret = strcatf(str, "" - "
" - "x-container/folder" - "x-container/folder" - "%s" - "%d" - "
" - "" - "" - "/TiVoConnect?Command=QueryContainer&Container=%s" - "x-tivo-container/folder" - "" - "", - unescape_tag(title), count, id); + strcatf(str, "" + "
" + "x-container/folder" + "x-container/folder" + "%s" + "%d" + "
" + "" + "" + "/TiVoConnect?Command=QueryContainer&Container=%s" + "x-tivo-container/folder" + "" + "", + unescape_tag(title), count, id); } - ret = strcatf(str, "
"); + strcatf(str, "
"); passed_args->returned++;