Fix Clang compiler warnings.

This commit is contained in:
Justin Maggard 2014-03-07 12:42:40 -08:00
parent 546b12e1a9
commit a606012d23
3 changed files with 10 additions and 9 deletions

View File

@ -421,7 +421,7 @@ writepidfile(const char *fname, int pid, uid_t uid)
fname);
return -1;
}
if (uid >= 0)
if (uid > 0)
{
if (chown(dir, uid, -1) != 0)
DPRINTF(E_WARN, L_GENERAL, "Unable to change pidfile ownership: %s\n",
@ -443,7 +443,7 @@ writepidfile(const char *fname, int pid, uid_t uid)
"Unable to write to pidfile %s: %s\n", fname);
ret = -1;
}
if (uid >= 0)
if (uid > 0)
{
if (fchown(fileno(pidfile), uid, -1) != 0)
DPRINTF(E_WARN, L_GENERAL, "Unable to change pidfile ownership: %s\n",
@ -483,7 +483,7 @@ init(int argc, char **argv)
struct media_dir_s *media_dir;
int ifaces = 0;
media_types types;
uid_t uid = -1;
uid_t uid = 0;
/* first check if "-f" option is used */
for (i=2; i<argc; i++)
@ -694,7 +694,7 @@ init(int argc, char **argv)
strcpy(uuidvalue+5, ary_options[i].value);
break;
case USER_ACCOUNT:
uid = strtol(ary_options[i].value, &string, 0);
uid = strtoul(ary_options[i].value, &string, 0);
if (*string)
{
/* Symbolic username given, not UID. */
@ -818,7 +818,7 @@ init(int argc, char **argv)
if (i+1 != argc)
{
i++;
uid = strtol(argv[i], &string, 0);
uid = strtoul(argv[i], &string, 0);
if (*string)
{
/* Symbolic username given, not UID. */
@ -943,7 +943,7 @@ init(int argc, char **argv)
if (writepidfile(pidfilename, pid, uid) != 0)
pidfilename = NULL;
if (uid >= 0)
if (uid > 0)
{
struct stat st;
if (stat(db_path, &st) == 0 && st.st_uid != uid && chown(db_path, uid, -1) != 0)
@ -951,7 +951,7 @@ init(int argc, char **argv)
db_path, uid, strerror(errno));
}
if (uid != -1 && setuid(uid) == -1)
if (uid > 0 && setuid(uid) == -1)
DPRINTF(E_FATAL, L_GENERAL, "Failed to switch to uid '%d'. [%s] EXITING.\n",
uid, strerror(errno));

View File

@ -100,7 +100,7 @@ _get_wavtags(char *filename, struct song_metadata *psong)
// isprint(hdr[3]) ? hdr[3] : '?',
// block_len);
if(block_len < 0)
if(block_len > psong->file_size)
{
close(fd);
DPRINTF(E_WARN, L_SCANNER, "Bad block len: %s\n", filename);

3
uuid.c
View File

@ -102,7 +102,8 @@ read_random_bytes(unsigned char *buf, size_t size)
i = open("/dev/urandom", O_RDONLY);
if(i >= 0)
{
if(read(i, buf, size));
if (read(i, buf, size) == -1)
DPRINTF(E_MAXDEBUG, L_GENERAL, "Failed to read random bytes\n");
close(i);
}
/* Paranoia. /dev/urandom may be missing.