Fix some warnings from newer compilers

This commit is contained in:
Justin Maggard 2020-09-25 17:48:07 -07:00 committed by Justin Maggard
parent 9fba41008a
commit 9f1677825c
10 changed files with 35 additions and 22 deletions

View File

@ -489,7 +489,9 @@ AC_CHECK_LIB(avahi-client, avahi_threaded_poll_new,
################################################################################################################ ################################################################################################################
### Header checks ### Header checks
AC_CHECK_HEADERS([arpa/inet.h asm/unistd.h endian.h machine/endian.h fcntl.h libintl.h locale.h netdb.h netinet/in.h stddef.h stdlib.h string.h sys/file.h sys/inotify.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h unistd.h]) AC_CHECK_HEADERS([arpa/inet.h asm/unistd.h endian.h machine/endian.h fcntl.h libintl.h locale.h netdb.h netinet/in.h poll.h stddef.h stdlib.h string.h sys/file.h sys/inotify.h sys/ioctl.h sys/param.h sys/queue.h sys/socket.h sys/time.h unistd.h])
test x"$ac_cv_header_poll_h" != x"yes" && AC_MSG_ERROR([poll.h not found or not usable])
test x"$ac_cv_header_sys_queue_h" != x"yes" && AC_MSG_ERROR([sys/queue.h not found or not usable])
AC_CHECK_FUNCS(inotify_init, AC_DEFINE(HAVE_INOTIFY,1,[Whether kernel has inotify support]), [ AC_CHECK_FUNCS(inotify_init, AC_DEFINE(HAVE_INOTIFY,1,[Whether kernel has inotify support]), [
AC_MSG_CHECKING([for __NR_inotify_init syscall]) AC_MSG_CHECKING([for __NR_inotify_init syscall])

View File

@ -1,7 +1,7 @@
#include "config.h" #include "config.h"
#ifdef HAVE_KQUEUE
#include <sys/types.h> #include <sys/types.h>
#ifdef HAVE_KQUEUE
#include <sys/event.h> #include <sys/event.h>
#endif #endif

View File

@ -224,3 +224,11 @@ lav_is_thumbnail_stream(AVStream *s, uint8_t **data, int *size)
#endif #endif
return 0; return 0;
} }
static inline void
lav_register_all(void)
{
#if LIBAVFORMAT_VERSION_INT < ((58<<16)+(9<<8)+100)
av_register_all();
#endif
}

View File

@ -232,7 +232,7 @@ static void
getfriendlyname(char *buf, int len) getfriendlyname(char *buf, int len)
{ {
char *p = NULL; char *p = NULL;
char hn[256]; char hn[63];
int off; int off;
if (gethostname(hn, sizeof(hn)) == 0) if (gethostname(hn, sizeof(hn)) == 0)
@ -576,8 +576,7 @@ init(int argc, char **argv)
DPRINTF(E_OFF, L_GENERAL, "No MAC address found. Falling back to generic UUID.\n"); DPRINTF(E_OFF, L_GENERAL, "No MAC address found. Falling back to generic UUID.\n");
strcpy(mac_str, "554e4b4e4f57"); strcpy(mac_str, "554e4b4e4f57");
} }
strcpy(uuidvalue+5, "4d696e69-444c-164e-9d41-"); snprintf(uuidvalue+5, UUIDVALUE_MAX_LEN-5, "4d696e69-444c-164e-9d41-%s", mac_str);
strncat(uuidvalue, mac_str, 12);
getfriendlyname(friendly_name, FRIENDLYNAME_MAX_LEN); getfriendlyname(friendly_name, FRIENDLYNAME_MAX_LEN);
@ -1148,7 +1147,7 @@ main(int argc, char **argv)
#ifdef HAVE_KQUEUE #ifdef HAVE_KQUEUE
if (!GETFLAG(SCANNING_MASK)) { if (!GETFLAG(SCANNING_MASK)) {
av_register_all(); lav_register_all();
kqueue_monitor_start(); kqueue_monitor_start();
} }
#endif /* HAVE_KQUEUE */ #endif /* HAVE_KQUEUE */
@ -1274,7 +1273,7 @@ main(int argc, char **argv)
if (_get_dbtime() != lastdbtime) if (_get_dbtime() != lastdbtime)
updateID++; updateID++;
#ifdef HAVE_KQUEUE #ifdef HAVE_KQUEUE
av_register_all(); lav_register_all();
kqueue_monitor_start(); kqueue_monitor_start();
#endif /* HAVE_KQUEUE */ #endif /* HAVE_KQUEUE */
} }

View File

@ -104,7 +104,10 @@ raise_watch_limit(unsigned int limit)
if (!max_watches) if (!max_watches)
return; return;
if (!limit) if (!limit)
fscanf(max_watches, "%u", &limit); {
if (fscanf(max_watches, "%u", &limit) < 1)
limit = 8192;
}
fprintf(max_watches, "%u", next_highest(limit)); fprintf(max_watches, "%u", next_highest(limit));
fclose(max_watches); fclose(max_watches);
} }
@ -643,7 +646,7 @@ start_inotify(void)
if (setpriority(PRIO_PROCESS, 0, 19) == -1) if (setpriority(PRIO_PROCESS, 0, 19) == -1)
DPRINTF(E_WARN, L_INOTIFY, "Failed to reduce inotify thread priority\n"); DPRINTF(E_WARN, L_INOTIFY, "Failed to reduce inotify thread priority\n");
sqlite3_release_memory(1<<31); sqlite3_release_memory(1<<31);
av_register_all(); lav_register_all();
while( !quitting ) while( !quitting )
{ {

View File

@ -62,7 +62,7 @@ int valid_cache = 0;
struct virtual_item struct virtual_item
{ {
int64_t objectID; int64_t objectID;
char parentID[64]; char parentID[80];
char name[256]; char name[256];
}; };
@ -203,7 +203,7 @@ insert_containers(const char *name, const char *path, const char *refID, const c
else else
{ {
insert_container(date_taken, last_cam.parentID, NULL, "album.photoAlbum", NULL, NULL, NULL, &objectID, &parentID); insert_container(date_taken, last_cam.parentID, NULL, "album.photoAlbum", NULL, NULL, NULL, &objectID, &parentID);
sprintf(last_camdate.parentID, "%s$%llX", last_cam.parentID, (long long)parentID); sprintf(last_camdate.parentID, "%.63s$%llX", last_cam.parentID, (long long)parentID);
last_camdate.objectID = objectID; last_camdate.objectID = objectID;
strncpyt(last_camdate.name, date_taken, sizeof(last_camdate.name)); strncpyt(last_camdate.name, date_taken, sizeof(last_camdate.name));
//DEBUG DPRINTF(E_DEBUG, L_SCANNER, "Creating cached camdate item: %s/%s/%s/%X\n", camera, last_camdate.name, last_camdate.parentID, last_camdate.objectID); //DEBUG DPRINTF(E_DEBUG, L_SCANNER, "Creating cached camdate item: %s/%s/%s/%X\n", camera, last_camdate.name, last_camdate.parentID, last_camdate.objectID);
@ -277,7 +277,7 @@ insert_containers(const char *name, const char *path, const char *refID, const c
last_artistAlbum.name[0] = '\0'; last_artistAlbum.name[0] = '\0';
/* Add this file to the "- All Albums -" container as well */ /* Add this file to the "- All Albums -" container as well */
insert_container(_("- All Albums -"), last_artist.parentID, NULL, "album", artist, genre, NULL, &objectID, &parentID); insert_container(_("- All Albums -"), last_artist.parentID, NULL, "album", artist, genre, NULL, &objectID, &parentID);
sprintf(last_artistAlbumAll.parentID, "%s$%llX", last_artist.parentID, (long long)parentID); sprintf(last_artistAlbumAll.parentID, "%.63s$%llX", last_artist.parentID, (long long)parentID);
last_artistAlbumAll.objectID = objectID; last_artistAlbumAll.objectID = objectID;
} }
else else
@ -293,7 +293,7 @@ insert_containers(const char *name, const char *path, const char *refID, const c
{ {
insert_container(album?album:_("Unknown Album"), last_artist.parentID, album?last_album.parentID:NULL, insert_container(album?album:_("Unknown Album"), last_artist.parentID, album?last_album.parentID:NULL,
"album.musicAlbum", artist, genre, album_art, &objectID, &parentID); "album.musicAlbum", artist, genre, album_art, &objectID, &parentID);
sprintf(last_artistAlbum.parentID, "%s$%llX", last_artist.parentID, (long long)parentID); sprintf(last_artistAlbum.parentID, "%.63s$%llX", last_artist.parentID, (long long)parentID);
last_artistAlbum.objectID = objectID; last_artistAlbum.objectID = objectID;
strncpyt(last_artistAlbum.name, album ? album : _("Unknown Album"), sizeof(last_artistAlbum.name)); strncpyt(last_artistAlbum.name, album ? album : _("Unknown Album"), sizeof(last_artistAlbum.name));
//DEBUG DPRINTF(E_DEBUG, L_SCANNER, "Creating cached artist/album item: %s/%s/%X\n", last_artist.name, last_artist.parentID, last_artist.objectID); //DEBUG DPRINTF(E_DEBUG, L_SCANNER, "Creating cached artist/album item: %s/%s/%X\n", last_artist.name, last_artist.parentID, last_artist.objectID);
@ -318,7 +318,7 @@ insert_containers(const char *name, const char *path, const char *refID, const c
strncpyt(last_genre.name, genre, sizeof(last_genre.name)); strncpyt(last_genre.name, genre, sizeof(last_genre.name));
/* Add this file to the "- All Artists -" container as well */ /* Add this file to the "- All Artists -" container as well */
insert_container(_("- All Artists -"), last_genre.parentID, NULL, "person", NULL, genre, NULL, &objectID, &parentID); insert_container(_("- All Artists -"), last_genre.parentID, NULL, "person", NULL, genre, NULL, &objectID, &parentID);
sprintf(last_genreArtistAll.parentID, "%s$%llX", last_genre.parentID, (long long)parentID); sprintf(last_genreArtistAll.parentID, "%.63s$%llX", last_genre.parentID, (long long)parentID);
last_genreArtistAll.objectID = objectID; last_genreArtistAll.objectID = objectID;
} }
else else
@ -333,7 +333,7 @@ insert_containers(const char *name, const char *path, const char *refID, const c
{ {
insert_container(artist?artist:_("Unknown Artist"), last_genre.parentID, artist?last_artist.parentID:NULL, insert_container(artist?artist:_("Unknown Artist"), last_genre.parentID, artist?last_artist.parentID:NULL,
"person.musicArtist", NULL, genre, NULL, &objectID, &parentID); "person.musicArtist", NULL, genre, NULL, &objectID, &parentID);
sprintf(last_genreArtist.parentID, "%s$%llX", last_genre.parentID, (long long)parentID); sprintf(last_genreArtist.parentID, "%.63s$%llX", last_genre.parentID, (long long)parentID);
last_genreArtist.objectID = objectID; last_genreArtist.objectID = objectID;
strncpyt(last_genreArtist.name, artist ? artist : _("Unknown Artist"), sizeof(last_genreArtist.name)); strncpyt(last_genreArtist.name, artist ? artist : _("Unknown Artist"), sizeof(last_genreArtist.name));
//DEBUG DPRINTF(E_DEBUG, L_SCANNER, "Creating cached genre/artist item: %s/%s/%X\n", last_genreArtist.name, last_genreArtist.parentID, last_genreArtist.objectID); //DEBUG DPRINTF(E_DEBUG, L_SCANNER, "Creating cached genre/artist item: %s/%s/%X\n", last_genreArtist.name, last_genreArtist.parentID, last_genreArtist.objectID);
@ -491,7 +491,7 @@ insert_file(const char *name, const char *path, const char *parentID, int object
return -1; return -1;
} }
sprintf(objectID, "%s%s$%X", BROWSEDIR_ID, parentID, object); snprintf(objectID, sizeof(objectID), "%s%s$%X", BROWSEDIR_ID, parentID, object);
objname = strdup(name); objname = strdup(name);
strip_ext(objname); strip_ext(objname);
@ -901,7 +901,7 @@ start_scanner(void)
DPRINTF(E_WARN, L_INOTIFY, "Failed to reduce scanner thread priority\n"); DPRINTF(E_WARN, L_INOTIFY, "Failed to reduce scanner thread priority\n");
setlocale(LC_COLLATE, ""); setlocale(LC_COLLATE, "");
av_register_all(); lav_register_all();
av_log_set_level(AV_LOG_PANIC); av_log_set_level(AV_LOG_PANIC);
if( GETFLAG(RESCAN_MASK) ) if( GETFLAG(RESCAN_MASK) )
@ -919,7 +919,7 @@ start_scanner(void)
{ {
int startID = get_next_available_id("OBJECTS", BROWSEDIR_ID); int startID = get_next_available_id("OBJECTS", BROWSEDIR_ID);
id = insert_directory(bname, path, BROWSEDIR_ID, "", startID); id = insert_directory(bname, path, BROWSEDIR_ID, "", startID);
sprintf(buf, "$%X", startID); snprintf(buf, sizeof(buf), "$%X", startID);
parent = buf; parent = buf;
} }
else else

View File

@ -172,7 +172,7 @@ _get_dfffileinfo(char *file, struct song_metadata *psong)
count += 4; count += 4;
cmprckDataSize = GET_DFF_INT64(propckData + count); cmprckDataSize = GET_DFF_INT64(propckData + count);
count += 8; count += 8;
strncpy((char*)compressionType, (char*)propckData + count, 4); memcpy(compressionType, propckData + count, 4);
count += cmprckDataSize; count += cmprckDataSize;
} }
else if (strncmp((char*)propckData + count, "ABSS", 4) == 0) else if (strncmp((char*)propckData + count, "ABSS", 4) == 0)

View File

@ -44,7 +44,7 @@
#include <netinet/in.h> #include <netinet/in.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <net/if.h> #include <net/if.h>
#include <sys/poll.h> #include <poll.h>
#include <netdb.h> #include <netdb.h>
#include "event.h" #include "event.h"

View File

@ -211,6 +211,7 @@ extern uint32_t runtime_flags;
extern const char *pidfilename; extern const char *pidfilename;
#define UUIDVALUE_MAX_LEN 42
extern char uuidvalue[]; extern char uuidvalue[];
#define MODELNAME_MAX_LEN 64 #define MODELNAME_MAX_LEN 64

View File

@ -53,8 +53,8 @@ strcatf(struct string_s *str, const char *fmt, ...)
} }
static inline void strncpyt(char *dst, const char *src, size_t len) static inline void strncpyt(char *dst, const char *src, size_t len)
{ {
strncpy(dst, src, len); strncpy(dst, src, --len);
dst[len-1] = '\0'; dst[len] = '\0';
} }
static inline int is_reg(const struct dirent *d) static inline int is_reg(const struct dirent *d)
{ {