Browse code

Fixed compiler warnings reported on Ubuntu 10.04

The warnings reported where:
--------------------------------------------------------
misc.c:158: warning: ignoring return value of ‘nice’, declared with attribute warn_unused_result
options.c:4033: warning: format not a string literal and no format arguments
options.c:4043: warning: format not a string literal and no format arguments
options.c:4053: warning: format not a string literal and no format arguments
push.c:182: warning: format not a string literal and no format arguments
push.c:199: warning: format not a string literal and no format arguments
push.c:235: warning: format not a string literal and no format arguments
status.c:171: warning: ignoring return value of ‘ftruncate’, declared with attribute warn_unused_result
--------------------------------------------------------

Signed-off-by: David Sommerseth <dazo@users.sourceforge.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Peter Stuge <peter@stuge.se>

David Sommerseth authored on 2010/09/18 00:10:25
Showing 4 changed files
... ...
@@ -155,9 +155,8 @@ set_nice (int niceval)
155 155
     {
156 156
 #ifdef HAVE_NICE
157 157
       errno = 0;
158
-      nice (niceval);
159
-      if (errno != 0)
160
-	msg (M_WARN | M_ERRNO, "WARNING: nice %d failed", niceval);
158
+      if (nice (niceval) < 0 && errno != 0)
159
+	msg (M_WARN | M_ERRNO, "WARNING: nice %d failed: %s", niceval, strerror(errno));
161 160
       else
162 161
 	msg (M_INFO, "nice %d succeeded", niceval);
163 162
 #else
... ...
@@ -4014,7 +4014,7 @@ add_option (struct options *options,
4014 4014
 		    {
4015 4015
 		      if (options->inetd != -1)
4016 4016
 			{
4017
-			  msg (msglevel, opterr);
4017
+			  msg (msglevel, "%s", opterr);
4018 4018
 			  goto err;
4019 4019
 			}
4020 4020
 		      else
... ...
@@ -4024,7 +4024,7 @@ add_option (struct options *options,
4024 4024
 		    {
4025 4025
 		      if (options->inetd != -1)
4026 4026
 			{
4027
-			  msg (msglevel, opterr);
4027
+			  msg (msglevel, "%s", opterr);
4028 4028
 			  goto err;
4029 4029
 			}
4030 4030
 		      else
... ...
@@ -4034,7 +4034,7 @@ add_option (struct options *options,
4034 4034
 		    {
4035 4035
 		      if (name != NULL)
4036 4036
 			{
4037
-			  msg (msglevel, opterr);
4037
+			  msg (msglevel, "%s", opterr);
4038 4038
 			  goto err;
4039 4039
 			}
4040 4040
 		      name = p[z];
... ...
@@ -179,7 +179,7 @@ send_push_reply (struct context *c)
179 179
   const int safe_cap = BCAP (&buf) - extra;
180 180
   bool push_sent = false;
181 181
 
182
-  buf_printf (&buf, cmd);
182
+  buf_printf (&buf, "%s", cmd);
183 183
 
184 184
   while (e)
185 185
     {
... ...
@@ -196,7 +196,7 @@ send_push_reply (struct context *c)
196 196
 		push_sent = true;
197 197
 		multi_push = true;
198 198
 		buf_reset_len (&buf);
199
-		buf_printf (&buf, cmd);
199
+		buf_printf (&buf, "%s", cmd);
200 200
 	      }
201 201
 	    }
202 202
 	  if (BLEN (&buf) + l >= safe_cap)
... ...
@@ -232,7 +232,7 @@ send_push_reply (struct context *c)
232 232
       bool status = false;
233 233
 
234 234
       buf_reset_len (&buf);
235
-      buf_printf (&buf, cmd);
235
+      buf_printf (&buf, "%s", cmd);
236 236
       status = send_control_channel_string (c, BSTR(&buf), D_PUSH);
237 237
       if (!status)
238 238
 	goto fail;
... ...
@@ -168,7 +168,9 @@ status_flush (struct status_output *so)
168 168
 #if defined(HAVE_FTRUNCATE)
169 169
       {
170 170
 	const off_t off = lseek (so->fd, (off_t)0, SEEK_CUR);
171
-	ftruncate (so->fd, off);
171
+	if (ftruncate (so->fd, off) != 0) {
172
+	  msg (M_WARN, "Failed to truncate status file: %s", strerror(errno));
173
+	}
172 174
       }
173 175
 #elif defined(HAVE_CHSIZE)
174 176
       {