[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Fix most warnings with gcc 4.4 on Linux.
From: |
Boris Dusek |
Subject: |
[PATCH] Fix most warnings with gcc 4.4 on Linux. |
Date: |
Tue, 7 Sep 2010 14:33:05 +0200 |
Reviewed-by: Christopher Brannon <cmbrannon79 at gmail.com>
Modified by Christopher Brannon: fix rebase conflicts.
---
src/audio/alsa.c | 6 +++++-
src/audio/oss.c | 4 ++--
src/audio/pulse.c | 3 +--
src/c/api/libspeechd.c | 1 -
src/c/clients/spdsend/server.c | 9 ++++++---
src/c/clients/spdsend/spdsend.c | 5 +++--
src/modules/cicero.c | 14 +-------------
src/modules/espeak.c | 6 +++---
src/modules/festival.c | 6 +++---
src/modules/festival_client.c | 2 +-
src/modules/festival_client.h | 6 +++---
src/modules/flite.c | 2 ++
src/modules/ivona.c | 3 ++-
src/modules/module_utils.c | 8 ++++----
src/server/Makefile.am | 2 +-
src/server/history.c | 8 ++++----
src/server/history.h | 2 +-
src/server/module.c | 2 --
src/server/options.c | 18 ++++++++++++++++++
src/server/options.h | 18 ------------------
src/server/parse.c | 3 ++-
src/server/sem_functions.c | 4 +++-
src/server/speaking.c | 7 +++++--
src/server/speechd.c | 16 +++++-----------
src/server/speechd.h | 2 --
src/tests/run_test.c | 7 +++++--
26 files changed, 80 insertions(+), 84 deletions(-)
diff --git a/src/audio/alsa.c b/src/audio/alsa.c
index 12da8ea..f381ccf 100644
--- a/src/audio/alsa.c
+++ b/src/audio/alsa.c
@@ -318,7 +318,8 @@ int wait_for_poll(spd_alsa_id_t *id, struct pollfd
*alsa_poll_fds,
/* Check for stop request from alsa_stop on the last file
descriptors*/
- if (revents = id->alsa_poll_fds[count-1].revents){
+ revents = id->alsa_poll_fds[count-1].revents;
+ if (0 != revents){
if (revents & POLLIN){
MSG(4, "wait_for_poll: stop requested");
return 1;
@@ -493,6 +494,9 @@ alsa_play(AudioID *id, AudioTrack track)
case SPD_AUDIO_BE:
format = SND_PCM_FORMAT_S16_BE;
break;
+ default:
+ ERR("unknown audio format (%d)", alsa_id->id.format);
+ return -1;
}
bytes_per_sample = 2;
}else if (track.bits == 8){
diff --git a/src/audio/oss.c b/src/audio/oss.c
index 5ae1203..4254b60 100644
--- a/src/audio/oss.c
+++ b/src/audio/oss.c
@@ -189,7 +189,7 @@ oss_play(AudioID *id, AudioTrack track)
struct timeval now;
struct timespec timeout;
float lenght;
- int r;
+ int r = 0;
int format, oformat, channels, speed;
int bytes_per_sample;
int num_bytes;
@@ -423,7 +423,7 @@ oss_play(AudioID *id, AudioTrack track)
static int
oss_stop(AudioID *id)
{
- int ret;
+ int ret = 0;
spd_oss_id_t * oss_id = (spd_oss_id_t *)id;
if (oss_id == NULL) return 0;
diff --git a/src/audio/pulse.c b/src/audio/pulse.c
index 90d2c9f..f4d4c12 100644
--- a/src/audio/pulse.c
+++ b/src/audio/pulse.c
@@ -63,10 +63,9 @@ typedef struct {
static int pulse_log_level;
static char const * pulse_play_cmd="paplay";
-static FILE *pulseDebugFile = NULL;
-
/* Write to /tmp/speech-dispatcher-pulse.log */
#ifdef DEBUG_PULSE
+static FILE *pulseDebugFile = NULL;
static void MSG(char *message, ...)
{
va_list ap;
diff --git a/src/c/api/libspeechd.c b/src/c/api/libspeechd.c
index 1c9474d..5d4a65a 100644
--- a/src/c/api/libspeechd.c
+++ b/src/c/api/libspeechd.c
@@ -284,7 +284,6 @@ spawn_server(SPDConnectionAddress *address, int
is_localhost, gchar **spawn_erro
GError *gerror = NULL;
int exit_status;
int i;
- char *resolved_ip;
if ((address->method==SPD_METHOD_INET_SOCKET) && (!is_localhost)){
*spawn_error = g_strdup("Spawn failed, the given network address
doesn't seem to be on localhost");
diff --git a/src/c/clients/spdsend/server.c b/src/c/clients/spdsend/server.c
index 83e3afd..1b45f01 100644
--- a/src/c/clients/spdsend/server.c
+++ b/src/c/clients/spdsend/server.c
@@ -293,8 +293,8 @@ static void process_data (Stream s)
else
report_error (s);
- do_send_data (id, s, NONE, forward_data) == OK &&
- do_send_data (id, NONE, s, forward_ssip_answer) == OK;
+ if (do_send_data (id, s, NONE, forward_data) == OK)
+ do_send_data (id, NONE, s, forward_ssip_answer);
}
@@ -392,13 +392,16 @@ static void serve ()
static void daemonize ()
{
+ int ret = 0;
if (fork () != 0)
exit (0);
setsid ();
signal (SIGHUP, SIG_IGN);
if (fork () != 0)
exit (0);
- chdir ("/");
+ if ((ret = chdir ("/")) != 0)
+ fputs("server.c:daemonize: could not chdir", stderr);
+ exit (1);
umask (0);
{
int i;
diff --git a/src/c/clients/spdsend/spdsend.c b/src/c/clients/spdsend/spdsend.c
index f459e55..708096a 100644
--- a/src/c/clients/spdsend/spdsend.c
+++ b/src/c/clients/spdsend/spdsend.c
@@ -117,7 +117,8 @@ int main (int argc, char **argv)
exit (EXIT_OK);
}
- if (! strcmp (action, "--open"))
+ const int action_is_open = strcmp (action, "--open") == 0;
+ if (action_is_open)
{
if (argc != 4)
usage ("Invalid number of arguments");
@@ -144,7 +145,7 @@ int main (int argc, char **argv)
return EXIT_ERROR;
{
- int result = (! strcmp (action, "--open")
+ int result = (action_is_open
? open_connection (server, host, port)
: function (server, conn_id));
return (result == OK ? EXIT_OK : EXIT_ERROR);
diff --git a/src/modules/cicero.c b/src/modules/cicero.c
index fb373f4..2540abe 100644
--- a/src/modules/cicero.c
+++ b/src/modules/cicero.c
@@ -52,9 +52,6 @@ static unsigned int CiceroMaxChunkLength = 500;
/* Internal functions prototypes */
static void cicero_set_rate(signed int rate);
-static void cicero_set_pitch(signed int pitch);
-static void cicero_set_volume(signed int pitch);
-static void cicero_set_voice(EVoiceType voice);
static void* _cicero_speak(void*);
@@ -395,7 +392,7 @@ _cicero_speak(void* nothing)
break;
}
if (ret > 0)
- read(fd1[0], b, 2);
+ TEMP_FAILURE_RETRY(read(fd1[0], b, 2));
if (cicero_stop) {
cicero_speaking = 0;
module_report_event_stop();
@@ -467,12 +464,3 @@ cicero_set_rate(signed int rate)
}
-static void
-cicero_set_pitch(signed int pitch)
-{
-}
-
-static void
-cicero_set_voice(EVoiceType voice)
-{
-}
diff --git a/src/modules/espeak.c b/src/modules/espeak.c
index 60755a9..c96d757 100644
--- a/src/modules/espeak.c
+++ b/src/modules/espeak.c
@@ -347,7 +347,7 @@ module_speak(gchar *data, size_t bytes, EMessageType
msgtype)
pthread_mutex_unlock(&espeak_state_mutex);
return FATAL_ERROR;
}
- DBG("Espeak: Requested data: |%s| %d %ld", data, msgtype, bytes);
+ DBG("Espeak: Requested data: |%s| %d %lu", data, msgtype, (unsigned
long) bytes);
espeak_state_reset();
espeak_state = BEFORE_SYNTH;
@@ -399,7 +399,7 @@ module_speak(gchar *data, size_t bytes, EMessageType
msgtype)
}
g_free(tmp);
}
- char *msg = g_strdup_printf("<say-as
interpret-as=\"tts:char\">&#%d;</say-as>", wc);
+ char *msg = g_strdup_printf("<say-as
interpret-as=\"tts:char\">&#%ld;</say-as>", (long)wc);
result = espeak_Synth(msg, strlen(msg) + 1, 0,
POS_CHARACTER, 0,
flags, NULL,
NULL);
g_free(msg);
@@ -1146,7 +1146,7 @@ espeak_play_file(char *filename)
sf = sf_open(filename, SFM_READ, &sfinfo);
subformat = sfinfo.format & SF_FORMAT_SUBMASK ;
items = sfinfo.channels * sfinfo.frames;
- DBG("Espeak: frames = %ld, channels = %d", sfinfo.frames,
sfinfo.channels);
+ DBG("Espeak: frames = %ld, channels = %ld", sfinfo.frames, (long)
sfinfo.channels);
DBG("Espeak: samplerate = %i, items = %Ld", sfinfo.samplerate, (long
long) items);
DBG("Espeak: major format = 0x%08X, subformat = 0x%08X, endian =
0x%08X",
sfinfo.format & SF_FORMAT_TYPEMASK, subformat, sfinfo.format &
SF_FORMAT_ENDMASK);
diff --git a/src/modules/festival.c b/src/modules/festival.c
index f0396ba..affef18 100644
--- a/src/modules/festival.c
+++ b/src/modules/festival.c
@@ -743,8 +743,8 @@ _festival_speak(void* nothing)
}
if (fwave->num_samples != 0){
- DBG("Sending message to audio: %ld bytes\n",
- (fwave->num_samples) * sizeof(short));
+ DBG("Sending message to audio: %lu bytes\n",
+ (long unsigned) ((fwave->num_samples) * sizeof(short)));
if(FestivalDebugSaveOutput){
char filename_debug[256];
@@ -951,7 +951,7 @@ cache_clean(size_t new_element_size)
GList *gl;
TCounterEntry *centry;
- DBG("Cache: cleaning, cache size %ld kbytes (>max %d).",
FestivalCache.size/1024,
+ DBG("Cache: cleaning, cache size %lu kbytes (>max %d).", (unsigned long)
(FestivalCache.size/1024),
FestivalCacheMaxKBytes);
req_size = 2*FestivalCache.size/3;
diff --git a/src/modules/festival_client.c b/src/modules/festival_client.c
index 3d85516..ba2de58 100644
--- a/src/modules/festival_client.c
+++ b/src/modules/festival_client.c
@@ -517,7 +517,7 @@ festival_speak_command(FT_Info *info, char *command, const
char *text, int symbo
str = g_strdup_printf("(%s \"", command);
else
str = g_strdup_printf("(%s '", command);
- fprintf(fd, str);
+ fputs(str, fd);
/* Copy text over to server, escaping any quotes */
for (p=text; p && (*p != '\0'); p++)
{
diff --git a/src/modules/festival_client.h b/src/modules/festival_client.h
index 5cd5784..8737321 100644
--- a/src/modules/festival_client.h
+++ b/src/modules/festival_client.h
@@ -85,8 +85,8 @@ void delete_FT_Info(FT_Info *info);
char *str; \
fd = fdopen(dup(info->server_fd),"wb"); \
if (fd != NULL){ \
- str = g_strdup_printf(format"\n"); \
- fprintf(fd, str); \
+ str = g_strdup(format"\n"); \
+ fputs(str, fd); \
DBG("-> Festival: |%s|", str); \
free(str); \
fclose(fd); \
@@ -102,7 +102,7 @@ void delete_FT_Info(FT_Info *info);
fd = fdopen(dup(info->server_fd),"wb"); \
if (fd != NULL){ \
str = g_strdup_printf(format"\n", args); \
- fprintf(fd, str); \
+ fputs(str, fd); \
DBG("-> Festival: |%s|", str); \
free(str); \
fclose(fd); \
diff --git a/src/modules/flite.c b/src/modules/flite.c
index 3f72ab8..bb052ea 100644
--- a/src/modules/flite.c
+++ b/src/modules/flite.c
@@ -366,6 +366,8 @@ _flite_speak(void* nothing)
case SPD_AUDIO_BE:
ret = spd_audio_play(module_audio_id, track,
SPD_AUDIO_BE);
break;
+ default:
+ FATAL("unknown audio format");
}
if (ret < 0) DBG("ERROR: spd_audio failed to play the
track");
if (flite_stop){
diff --git a/src/modules/ivona.c b/src/modules/ivona.c
index 182fd5c..e946463 100644
--- a/src/modules/ivona.c
+++ b/src/modules/ivona.c
@@ -315,7 +315,8 @@ static int ivona_get_msgpart(struct dumbtts_conf *conf,
EMessageType type,
{
int rc;
int isicon;
- int n,pos,bytes;
+ int n,bytes;
+ unsigned int pos;
wchar_t wc;
char xbuf[1024];
diff --git a/src/modules/module_utils.c b/src/modules/module_utils.c
index 10dfc26..b6d938f 100644
--- a/src/modules/module_utils.c
+++ b/src/modules/module_utils.c
@@ -813,11 +813,11 @@ module_child_dp_write(TModuleDoublePipe dpipe, const char
*msg, size_t bytes)
int
module_parent_dp_write(TModuleDoublePipe dpipe, const char *msg, size_t bytes)
{
- int ret;
+ ssize_t ret;
assert(msg != NULL);
- DBG("going to write %ld bytes", bytes);
+ DBG("going to write %lu bytes", (long unsigned) bytes);
ret = write(dpipe.pc[1], msg, bytes);
- DBG("written %d bytes", ret);
+ DBG("written %ld bytes", (long) ret);
return ret;
}
@@ -997,7 +997,7 @@ module_send_asynchronous(char *text)
{
pthread_mutex_lock(&module_stdout_mutex);
DBG("Printing reply: %s", text);
- fprintf(stdout, text);
+ fputs(text, stdout);
fflush(stdout);
DBG("Printed");
pthread_mutex_unlock(&module_stdout_mutex);
diff --git a/src/server/Makefile.am b/src/server/Makefile.am
index 2f54450..0c56c68 100644
--- a/src/server/Makefile.am
+++ b/src/server/Makefile.am
@@ -7,4 +7,4 @@ speech_dispatcher_LDFLAGS = @RDYNAMIC@
inc_local = -I$(top_srcdir)/intl/
localedir = $(datadir)/locale
-AM_CFLAGS = @ERROR_CFLAGS@ $(inc_local) -I$(localedir) @glib_include@
-DSYS_CONF=\"@address@hidden" -DSND_DATA=\"@address@hidden"
-DMODULEBINDIR=\"@address@hidden" -DVERSION=\"@address@hidden"
-DPACKAGE=\"@address@hidden"
+AM_CFLAGS = @ERROR_CFLAGS@ $(inc_local) -I$(localedir) @glib_include@
-DSYS_CONF=\"@address@hidden" -DSND_DATA=\"@address@hidden"
-DMODULEBINDIR=\"@address@hidden" -DVERSION=\"@address@hidden"
-DPACKAGE=\"@address@hidden" -D_GNU_SOURCE
diff --git a/src/server/history.c b/src/server/history.c
index b3703f8..17d8057 100644
--- a/src/server/history.c
+++ b/src/server/history.c
@@ -31,11 +31,11 @@
/* Compares TSpeechDMessage data structure elements
with given ID */
-int
-message_compare_id (gconstpointer element, gconstpointer value, gpointer n)
+gint
+message_compare_id (gconstpointer element, gconstpointer value)
{
- int ret;
- ret = ((TSpeechDMessage*) element)->id - (int) value;
+ gint ret;
+ ret = ((TSpeechDMessage*) element)->id - *((int *) value);
return ret;
}
diff --git a/src/server/history.h b/src/server/history.h
index f38f1aa..4703a03 100644
--- a/src/server/history.h
+++ b/src/server/history.h
@@ -44,7 +44,7 @@ char* history_get_message(int uid);
/* Internal functions */
GList* get_messages_by_client(int uid);
-int message_compare_id (gconstpointer element, gconstpointer value, gpointer
n);
+gint message_compare_id (gconstpointer element, gconstpointer value);
#endif /* HISTORY_H */
diff --git a/src/server/module.c b/src/server/module.c
index 538ba61..fb00184 100644
--- a/src/server/module.c
+++ b/src/server/module.c
@@ -22,8 +22,6 @@
* $Id: module.c,v 1.40 2008-07-07 14:30:51 hanke Exp $
*/
-#define _GNU_SOURCE
-
#include <sys/wait.h>
#include <sys/stat.h>
#include <stdio.h>
diff --git a/src/server/options.c b/src/server/options.c
index 1502dbc..628c8d1 100644
--- a/src/server/options.c
+++ b/src/server/options.c
@@ -30,6 +30,24 @@
#include "options.h"
+static const struct option spd_long_options[] = {
+ {"run-daemon", 0, 0, 'd'},
+ {"run-single", 0, 0, 's'},
+ {"spawn", 0, 0, 'a'},
+ {"log-level", 1, 0, 'l'},
+ {"communication-method", 1, 0, 'c'},
+ {"socket-path", 1, 0, 'S'},
+ {"port", 1, 0, 'p'},
+ {"pid-file", 1, 0, 'P'},
+ {"config-file", 1, 0, 'C'},
+ {"version", 0, 0, 'v'},
+ {"debug", 0, 0, 'D'},
+ {"help", 0, 0, 'h'},
+ {0, 0, 0, 0}
+};
+
+static const char *const spd_short_options = "dsal:c:S:p:P:C:vDh";
+
void
options_print_help(char *argv[])
{
diff --git a/src/server/options.h b/src/server/options.h
index bcc10c4..870502e 100644
--- a/src/server/options.h
+++ b/src/server/options.h
@@ -23,24 +23,6 @@
#include <getopt.h>
-static struct option spd_long_options[] = {
- {"run-daemon", 0, 0, 'd'},
- {"run-single", 0, 0, 's'},
- {"spawn", 0, 0, 'a'},
- {"log-level", 1, 0, 'l'},
- {"communication-method", 1, 0, 'c'},
- {"socket-path", 1, 0, 'S'},
- {"port", 1, 0, 'p'},
- {"pid-file", 1, 0, 'P'},
- {"config-file", 1, 0, 'C'},
- {"version", 0, 0, 'v'},
- {"debug", 0, 0, 'D'},
- {"help", 0, 0, 'h'},
- {0, 0, 0, 0}
-};
-
-static char* spd_short_options = "dsal:c:S:p:P:C:vDh";
-
void options_print_help(char *argv[]);
void options_print_version(void);
void options_parse(int argc, char *argv[]);
diff --git a/src/server/parse.c b/src/server/parse.c
index eae7d4e..196e7ca 100644
--- a/src/server/parse.c
+++ b/src/server/parse.c
@@ -384,7 +384,8 @@ char*
parse_set(const char *buf, const int bytes, const int fd, const TSpeechDSock
*speechd_socket)
{
int who; /* 0 - self, 1 - uid specified, 2 - all */
- int uid; /* uid of the client (only if who == 1) */
+ int uid = -1; /* uid of the client (only if who == 1) */
+ /* uid = -1 avoids gcc warning */
int ret = -1; // =-1 has no effect but avoids gcc warning
char *set_sub;
char *who_s;
diff --git a/src/server/sem_functions.c b/src/server/sem_functions.c
index d5debb4..6479eb5 100644
--- a/src/server/sem_functions.c
+++ b/src/server/sem_functions.c
@@ -30,5 +30,7 @@ speaking_semaphore_post(void)
{
char buf[1];
buf[0] = 42;
- write(speaking_pipe[1], buf, 1);
+ const ssize_t wr_bytes = TEMP_FAILURE_RETRY(write(speaking_pipe[1], buf,
1));
+ if (wr_bytes != 1)
+ FATAL("write to polled fd: could not write 1 byte");
}
diff --git a/src/server/speaking.c b/src/server/speaking.c
index 20d0977..6b5f487 100644
--- a/src/server/speaking.c
+++ b/src/server/speaking.c
@@ -24,6 +24,7 @@
#include <glib.h>
#include <poll.h>
+#include <unistd.h>
#include "speechd.h"
#include "server.h"
#include "index_marking.h"
@@ -79,9 +80,11 @@ speak(void* data)
poll_fds[0].revents, poll_fds[1].revents);
if( (revents = poll_fds[0].revents) ){
if (revents & POLLIN){
- char buf[100];
+ char buf[1];
MSG(5, "wait_for_poll: activity in Speech Dispatcher");
- read(poll_fds[0].fd, buf, 1);
+ const ssize_t rd_bytes =
TEMP_FAILURE_RETRY(read(poll_fds[0].fd, buf, 1));
+ if (rd_bytes != 1)
+ FATAL("read from polled fd: could not read 1 byte");
}
}
if (poll_count > 1){
diff --git a/src/server/speechd.c b/src/server/speechd.c
index bb6a1df..b0fe736 100644
--- a/src/server/speechd.c
+++ b/src/server/speechd.c
@@ -127,14 +127,10 @@ MSG2(int level, char *kind, char *format, ...)
if(std_log || custom_log) {
va_list args;
- va_list args2;
int i;
pthread_mutex_lock(&logging_mutex);
- if(std_log) va_start(args, format);
- if(custom_log) va_start(args2, format);
-
{
{
/* Print timestamp */
@@ -173,12 +169,16 @@ MSG2(int level, char *kind, char *format, ...)
}
}
if(std_log) {
+ va_start(args, format);
vfprintf(logfile, format, args);
+ va_end(args);
fprintf(logfile, "\n");
fflush(logfile);
}
if(custom_log) {
- vfprintf(custom_logfile, format, args2);
+ va_start(args, format);
+ vfprintf(custom_logfile, format, args);
+ va_end(args);
fprintf(custom_logfile, "\n");
fflush(custom_logfile);
}
@@ -190,12 +190,6 @@ MSG2(int level, char *kind, char *format, ...)
fflush(debug_logfile);
}
}
- if(std_log) {
- va_end(args);
- }
- if(custom_log) {
- va_end(args2);
- }
pthread_mutex_unlock(&logging_mutex);
}
}
diff --git a/src/server/speechd.h b/src/server/speechd.h
index 85fb984..fbfc65e 100644
--- a/src/server/speechd.h
+++ b/src/server/speechd.h
@@ -25,8 +25,6 @@
#ifndef SPEECHDH
#define SPEECHDH
-#define _GNU_SOURCE
-
#include <netinet/in.h>
#include <sys/types.h>
#include <sys/socket.h>
diff --git a/src/tests/run_test.c b/src/tests/run_test.c
index c516f2a..f2e87fa 100644
--- a/src/tests/run_test.c
+++ b/src/tests/run_test.c
@@ -23,6 +23,7 @@
*/
#include <stdio.h>
+#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
@@ -99,7 +100,7 @@ wait_for(int fd, char* event)
}
}
free(reply);
- printf(" Continuing.\n", reply);
+ printf(" Continuing.\n");
fflush(NULL);
}
@@ -297,7 +298,9 @@ main(int argc, char* argv[])
}
if(line[0] == '*'){
- system("clear");
+ int ret = system("clear");
+ if (ret == -1)
+ FATAL("Could not execute subprocess");
for (i=0; i<=indent - 1; i++){
printf("\n");
}
--
1.7.2.2
--=-=-=--