<URL: http://bugs.freeciv.org/Ticket/Display.html?id=40737 >

Fix the "O_CREAT 3-argument open" warning as reported by
Gorillaz on the forum, and replace an alloc macro in the
alsa sound code by equivalent code, since it was causing
a gcc warning:

audio_alsa.c: In function ‘set_hw_params’:
audio_alsa.c:108: error: the address of ‘hwparams’ will always evaluate 
as ‘true’

For more discussion about this warning, see
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=362422

This patch applies only to S2_0 since both problems have
already been fixed in S2_1 and trunk.


-----------------------------------------------------------------------
この主張は嘘である。
diff --git a/client/audio_alsa.c b/client/audio_alsa.c
index 5c9d7d7..bf670fb 100644
--- a/client/audio_alsa.c
+++ b/client/audio_alsa.c
@@ -105,7 +105,10 @@ static int set_hw_params(void)
   unsigned rrate;
   unsigned period_time = 100000;
 
-  snd_pcm_hw_params_alloca(&hwparams);
+  const size_t size = snd_pcm_hw_params_sizeof();
+  char hwparams_mem[size];
+  memset(hwparams_mem, 0, size);
+  hwparams = (snd_pcm_hw_params_t *) hwparams_mem;
 
   if (snd_pcm_hw_params_any(sound_handle, hwparams) < 0) {
     return -1;
diff --git a/client/connectdlg_common.c b/client/connectdlg_common.c
index 7b6ebd8..65eca14 100644
--- a/client/connectdlg_common.c
+++ b/client/connectdlg_common.c
@@ -253,7 +253,7 @@ bool client_start_server(void)
 
     /* include the port to avoid duplication */
     if (logfile) {
-      fd = open(logfile, O_WRONLY | O_CREAT);
+      fd = open(logfile, O_WRONLY | O_CREAT, 0644);
 
       if (fd != 1) {
         dup2(fd, 1);
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to