From 5818a2c63e9a52a545b9c8eb6fdbfa24cfee822f Mon Sep 17 00:00:00 2001 From: Maarten Bosmans Date: Thu, 23 Jun 2011 22:21:03 +0200 Subject: win32: Make some unused-variable warnings go away --- src/daemon/daemon-conf.c | 11 +++++++---- src/daemon/main.c | 2 ++ src/modules/module-augment-properties.c | 2 +- src/modules/module-cli.c | 2 ++ src/pulse/stream.c | 9 ++++----- src/pulse/timeval.c | 2 ++ src/pulse/util.c | 4 ++-- src/pulsecore/arpa-inet.c | 1 + src/pulsecore/cli-command.c | 4 +++- src/pulsecore/core-util.c | 21 +++++++++++++-------- src/pulsecore/dllmain.c | 2 +- src/pulsecore/random.c | 4 ++-- src/pulsecore/shm.c | 2 ++ src/pulsecore/socket-util.c | 8 +++++--- src/pulsecore/start-child.c | 4 ++-- 15 files changed, 49 insertions(+), 29 deletions(-) diff --git a/src/daemon/daemon-conf.c b/src/daemon/daemon-conf.c index 67b772ae..bb929091 100644 --- a/src/daemon/daemon-conf.c +++ b/src/daemon/daemon-conf.c @@ -470,6 +470,10 @@ static int parse_nice_level(const char *filename, unsigned line, const char *sec } static int parse_rtprio(const char *filename, unsigned line, const char *section, const char *lvalue, const char *rvalue, void *data, void *userdata) { +#ifdef OS_IS_WIN32 + pa_log("[%s:%u] Realtime priority not available on win32.", filename, line); +#else +# ifdef HAVE_SCHED_H pa_daemon_conf *c = data; int32_t rtprio; @@ -478,16 +482,15 @@ static int parse_rtprio(const char *filename, unsigned line, const char *section pa_assert(rvalue); pa_assert(data); -#ifndef OS_IS_WIN32 -# ifdef HAVE_SCHED_H if (pa_atoi(rvalue, &rtprio) < 0 || rtprio < sched_get_priority_min(SCHED_FIFO) || rtprio > sched_get_priority_max(SCHED_FIFO)) { pa_log("[%s:%u] Invalid realtime priority '%s'.", filename, line, rvalue); return -1; } -# endif -#endif c->realtime_priority = (int) rtprio; +# endif +#endif /* OS_IS_WIN32 */ + return 0; } diff --git a/src/daemon/main.c b/src/daemon/main.c index 90ed5ce0..94c87d15 100644 --- a/src/daemon/main.c +++ b/src/daemon/main.c @@ -748,7 +748,9 @@ int main(int argc, char *argv[]) { } if (conf->daemonize) { +#ifdef HAVE_FORK pid_t child; +#endif if (pa_stdio_acquire() < 0) { pa_log(_("Failed to acquire stdio.")); diff --git a/src/modules/module-augment-properties.c b/src/modules/module-augment-properties.c index bfc637aa..05f6f0a4 100644 --- a/src/modules/module-augment-properties.c +++ b/src/modules/module-augment-properties.c @@ -175,10 +175,10 @@ static void update_rule(struct rule *r) { if (stat(fn, &st) == 0) found = TRUE; else { +#ifdef DT_DIR DIR *desktopfiles_dir; struct dirent *dir; -#ifdef DT_DIR /* Let's try a more aggressive search, but only one level */ if ((desktopfiles_dir = opendir(DESKTOPFILEDIR))) { while ((dir = readdir(desktopfiles_dir))) { diff --git a/src/modules/module-cli.c b/src/modules/module-cli.c index 7788a756..2a1d1751 100644 --- a/src/modules/module-cli.c +++ b/src/modules/module-cli.c @@ -72,7 +72,9 @@ int pa__init(pa_module*m) { pa_iochannel *io; pa_modargs *ma; pa_bool_t exit_on_eof = FALSE; +#ifndef OS_IS_WIN32 int fd; +#endif pa_assert(m); diff --git a/src/pulse/stream.c b/src/pulse/stream.c index d60b864b..373bc346 100644 --- a/src/pulse/stream.c +++ b/src/pulse/stream.c @@ -790,11 +790,10 @@ void pa_command_stream_event(pa_pdispatch *pd, uint32_t command, uint32_t tag, p goto finish; if (pa_streq(event, PA_STREAM_EVENT_FORMAT_LOST)) { - /* Let client know what the running time was when the stream had to be - * killed */ - pa_usec_t time; - if (pa_stream_get_time(s, &time) == 0) - pa_proplist_setf(pl, "stream-time", "%llu", (unsigned long long) time); + /* Let client know what the running time was when the stream had to be killed */ + pa_usec_t stream_time; + if (pa_stream_get_time(s, &stream_time) == 0) + pa_proplist_setf(pl, "stream-time", "%llu", (unsigned long long) stream_time); } if (s->event_callback) diff --git a/src/pulse/timeval.c b/src/pulse/timeval.c index 10ba322f..b405a70a 100644 --- a/src/pulse/timeval.c +++ b/src/pulse/timeval.c @@ -49,6 +49,7 @@ struct timeval *pa_gettimeofday(struct timeval *tv) { #else #define EPOCHFILETIME (116444736000000000LL) #endif +{ FILETIME ft; LARGE_INTEGER li; int64_t t; @@ -61,6 +62,7 @@ struct timeval *pa_gettimeofday(struct timeval *tv) { t /= 10; /* In microseconds */ tv->tv_sec = (time_t) (t / PA_USEC_PER_SEC); tv->tv_usec = (suseconds_t) (t % PA_USEC_PER_SEC); +} #elif defined(HAVE_GETTIMEOFDAY) pa_assert_se(gettimeofday(tv, NULL) == 0); #else diff --git a/src/pulse/util.c b/src/pulse/util.c index ba1d2a08..6656bc3f 100644 --- a/src/pulse/util.c +++ b/src/pulse/util.c @@ -131,9 +131,9 @@ char *pa_get_host_name(char *s, size_t l) { } char *pa_get_home_dir(char *s, size_t l) { - char *e, *dir; - + char *e; #ifdef HAVE_PWD_H + char *dir; struct passwd *r; #endif diff --git a/src/pulsecore/arpa-inet.c b/src/pulsecore/arpa-inet.c index c927ca0b..09570bb0 100644 --- a/src/pulsecore/arpa-inet.c +++ b/src/pulsecore/arpa-inet.c @@ -29,6 +29,7 @@ #include #include +#include #include "arpa-inet.h" diff --git a/src/pulsecore/cli-command.c b/src/pulsecore/cli-command.c index e5c18065..16c76617 100644 --- a/src/pulsecore/cli-command.c +++ b/src/pulsecore/cli-command.c @@ -1574,8 +1574,10 @@ static int pa_cli_command_dump(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_b pa_card *card; pa_bool_t nl; uint32_t idx; - char txt[256]; time_t now; +#ifdef HAVE_CTIME_R + char txt[256]; +#endif pa_core_assert_ref(c); pa_assert(t); diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c index 6902ee98..f27f87ae 100644 --- a/src/pulsecore/core-util.c +++ b/src/pulsecore/core-util.c @@ -219,7 +219,7 @@ void pa_make_fd_cloexec(int fd) { /** Creates a directory securely */ int pa_make_secure_dir(const char* dir, mode_t m, uid_t uid, gid_t gid) { struct stat st; - int r, saved_errno, fd; + int r, saved_errno; pa_assert(dir); @@ -238,6 +238,8 @@ int pa_make_secure_dir(const char* dir, mode_t m, uid_t uid, gid_t gid) { return -1; #if defined(HAVE_FSTAT) && !defined(OS_IS_WIN32) +{ + int fd; if ((fd = open(dir, #ifdef O_CLOEXEC O_CLOEXEC| @@ -276,6 +278,7 @@ int pa_make_secure_dir(const char* dir, mode_t m, uid_t uid, gid_t gid) { #endif pa_assert_se(pa_close(fd) >= 0); +} #endif #ifdef HAVE_LSTAT @@ -728,7 +731,7 @@ int pa_make_realtime(int rtprio) { pa_log_info("Successfully acquired real-time thread priority."); return 0; -#elif _POSIX_PRIORITY_SCHEDULING +#elif defined(_POSIX_PRIORITY_SCHEDULING) int p; if (set_scheduler(rtprio) >= 0) { @@ -886,7 +889,6 @@ int pa_match(const char *expr, const char *v) { /* Try to parse a boolean string value.*/ int pa_parse_boolean(const char *v) { - const char *expr; pa_assert(v); /* First we check language independant */ @@ -896,6 +898,8 @@ int pa_parse_boolean(const char *v) { return 0; #ifdef HAVE_LANGINFO_H +{ + const char *expr; /* And then we check language dependant */ if ((expr = nl_langinfo(YESEXPR))) if (expr[0]) @@ -906,6 +910,7 @@ int pa_parse_boolean(const char *v) { if (expr[0]) if (pa_match(expr, v) > 0) return 0; +} #endif errno = EINVAL; @@ -1561,7 +1566,6 @@ static int make_random_dir_and_link(mode_t m, const char *k) { char *pa_get_runtime_dir(void) { char *d, *k = NULL, *p = NULL, *t = NULL, *mid; - struct stat st; mode_t m; /* The runtime directory shall contain dynamic data that needs NOT @@ -1641,10 +1645,10 @@ char *pa_get_runtime_dir(void) { goto fail; } - /* Hmm, so this symlink is still around, make sure nobody fools - * us */ - + /* Hmm, so this symlink is still around, make sure nobody fools us */ #ifdef HAVE_LSTAT +{ + struct stat st; if (lstat(p, &st) < 0) { if (errno != ENOENT) { @@ -1664,6 +1668,7 @@ char *pa_get_runtime_dir(void) { pa_log_info("Hmm, runtime path exists, but points to an invalid directory. Changing runtime directory."); } +} #endif pa_xfree(p); @@ -2203,7 +2208,7 @@ void *pa_will_need(const void *p, size_t l) { #endif const void *a; size_t size; - int r; + int r = ENOTSUP; size_t bs; pa_assert(p); diff --git a/src/pulsecore/dllmain.c b/src/pulsecore/dllmain.c index 3ee89673..d2de73d9 100644 --- a/src/pulsecore/dllmain.c +++ b/src/pulsecore/dllmain.c @@ -31,7 +31,7 @@ #include #include -extern pa_win32_get_toplevel(HANDLE handle); +extern char *pa_win32_get_toplevel(HANDLE handle); BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { WSADATA data; diff --git a/src/pulsecore/random.c b/src/pulsecore/random.c index 1bd69c2d..b2ec19f0 100644 --- a/src/pulsecore/random.c +++ b/src/pulsecore/random.c @@ -49,11 +49,11 @@ static int random_proper(void *ret_data, size_t length) { #ifdef OS_IS_WIN32 int ret = -1; + HCRYPTPROV hCryptProv = 0; + pa_assert(ret_data); pa_assert(length > 0); - HCRYPTPROV hCryptProv = NULL; - if (CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) { if(CryptGenRandom(hCryptProv, length, ret_data)) ret = 0; diff --git a/src/pulsecore/shm.c b/src/pulsecore/shm.c index da8aff70..442b698e 100644 --- a/src/pulsecore/shm.c +++ b/src/pulsecore/shm.c @@ -98,8 +98,10 @@ static char *segment_name(char *fn, size_t l, unsigned id) { #endif int pa_shm_create_rw(pa_shm *m, size_t size, pa_bool_t shared, mode_t mode) { +#ifdef HAVE_SHM_OPEN char fn[32]; int fd = -1; +#endif pa_assert(m); pa_assert(size > 0); diff --git a/src/pulsecore/socket-util.c b/src/pulsecore/socket-util.c index 46623c4d..00fcbc4f 100644 --- a/src/pulsecore/socket-util.c +++ b/src/pulsecore/socket-util.c @@ -72,8 +72,9 @@ void pa_socket_peer_to_string(int fd, char *c, size_t l) { #ifndef OS_IS_WIN32 pa_assert_se(fstat(fd, &st) == 0); - if (S_ISSOCK(st.st_mode)) { + if (S_ISSOCK(st.st_mode)) #endif + { union { struct sockaddr_storage storage; struct sockaddr sa; @@ -118,10 +119,11 @@ void pa_socket_peer_to_string(int fd, char *c, size_t l) { } } -#ifndef OS_IS_WIN32 pa_snprintf(c, l, "Unknown network client"); return; - } else if (S_ISCHR(st.st_mode) && (fd == 0 || fd == 1)) { + } +#ifndef OS_IS_WIN32 + else if (S_ISCHR(st.st_mode) && (fd == 0 || fd == 1)) { pa_snprintf(c, l, "STDIN/STDOUT client"); return; } diff --git a/src/pulsecore/start-child.c b/src/pulsecore/start-child.c index fd1baebb..7f55d4e2 100644 --- a/src/pulsecore/start-child.c +++ b/src/pulsecore/start-child.c @@ -45,10 +45,10 @@ #include "start-child.h" int pa_start_child_for_read(const char *name, const char *argv1, pid_t *pid) { +#ifdef HAVE_FORK pid_t child; int pipe_fds[2] = { -1, -1 }; -#ifdef HAVE_FORK if (pipe(pipe_fds) < 0) { pa_log("pipe() failed: %s", pa_cstrerror(errno)); goto fail; @@ -106,10 +106,10 @@ int pa_start_child_for_read(const char *name, const char *argv1, pid_t *pid) { execl(name, name, argv1, NULL); _exit(1); } -#endif fail: pa_close_pipe(pipe_fds); +#endif /* HAVE_FORK */ return -1; } -- cgit