]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
Fixed warn_unused_result warnings for read/write
authorMattias Wadman <mattias.wadman@gmail.com>
Fri, 10 Apr 2009 13:05:39 +0000 (13:05 +0000)
committerMattias Wadman <mattias.wadman@gmail.com>
Fri, 10 Apr 2009 13:05:39 +0000 (13:05 +0000)
Ignore for network io, handled for filesystem io

src/cwc.c
src/htsp.c
src/settings.c
src/webui/webui.c

index 5438d927c0d058adab4d03a4a802c7b6aa9a466c..0af1edae658e91a4d3013b09d36a94f2eb21567a 100644 (file)
--- a/src/cwc.c
+++ b/src/cwc.c
@@ -346,6 +346,7 @@ static int
 cwc_send_msg(cwc_t *cwc, const uint8_t *msg, size_t len, int sid)
 {
   uint8_t *buf = malloc(CWS_NETMSGSIZE);
+  int n;
 
   pthread_mutex_lock(&cwc->cwc_send_mutex);
 
@@ -370,7 +371,8 @@ cwc_send_msg(cwc_t *cwc, const uint8_t *msg, size_t len, int sid)
   buf[0] = (len - 2) >> 8;
   buf[1] =  len - 2;
 
-  write(cwc->cwc_fd, buf, len);
+  /* ignore return value */
+  n = write(cwc->cwc_fd, buf, len);
   free(buf);
   pthread_mutex_unlock(&cwc->cwc_send_mutex);
   return cwc->cwc_seq;
index 77b69abef8da90072db83dc1b09d4a114f8a78af..030faa7f071d06c37b298866616e0cbfa8753b43 100644 (file)
@@ -786,8 +786,9 @@ htsp_write_scheduler(void *aux)
     }
 #endif
     htsp_msg_destroy(hm);
-    
-    write(htsp->htsp_fd, dptr, dlen);
+   
+    /* ignore return value */ 
+    r = write(htsp->htsp_fd, dptr, dlen);
     free(dptr);
     pthread_mutex_lock(&htsp->htsp_out_mutex);
   }
index 2ccf552907b10bab8c3100c386090f328ce2e0d6..eeda2e1817d64faa0d7e56dc5e090592a813fba3 100644 (file)
@@ -86,6 +86,7 @@ hts_settings_save(htsmsg_t *record, const char *pathfmt, ...)
   htsbuf_queue_t hq;
   htsbuf_data_t *hd;
   char *n;
+  char ok;
 
   if(settingspath == NULL)
     return;
@@ -128,18 +129,26 @@ hts_settings_save(htsmsg_t *record, const char *pathfmt, ...)
     return;
   }
 
+  ok = 1;
+
   htsbuf_queue_init(&hq, 0);
   htsmsg_json_serialize(record, &hq, 1);
-
-  
   TAILQ_FOREACH(hd, &hq.hq_q, hd_link)
-    write(fd, hd->hd_data + hd->hd_data_off, hd->hd_data_len);
+    if(write(fd, hd->hd_data + hd->hd_data_off, hd->hd_data_len) != 
+       hd->hd_data_len) {
+      syslog(LOG_ALERT, "settings: Failed to write file \"%s\" - %s",
+             fullpath, strerror(errno));
+      ok = 0;
+      break;
+    }
 
   close(fd);
 
   snprintf(fullpath2, sizeof(fullpath2), "%s/%s", settingspath, path);
 
-  rename(fullpath, fullpath2);
+  if(ok)
+    rename(fullpath, fullpath2);
           
   htsbuf_queue_flush(&hq);
 }
@@ -154,6 +163,7 @@ hts_settings_load_one(const char *filename)
   int fd;
   char *mem;
   htsmsg_t *r;
+  int n;
 
   if(stat(filename, &st) < 0)
     return NULL;
@@ -164,11 +174,15 @@ hts_settings_load_one(const char *filename)
   mem = malloc(st.st_size + 1);
   mem[st.st_size] = 0;
 
-  read(fd, mem, st.st_size);
+  n = read(fd, mem, st.st_size);
   close(fd);
+  if(n == st.st_size)
+    r = htsmsg_json_deserialize(mem);
+  else
+    r = NULL;
 
-  r = htsmsg_json_deserialize(mem);
   free(mem);
+
   return r;
 }
 
index c53a5b282d02fbd199206340f3d61efdaf0832a7..180a78f4251f3bda92c91dc5d9a3680ce39c3967 100644 (file)
@@ -123,6 +123,7 @@ page_static_bundle(http_connection_t *hc, const char *remain, void *opaque)
   const struct filebundle *fb = opaque;
   const struct filebundle_entry *fbe;
   const char *content = NULL, *postfix;
+  int n;
 
   postfix = strrchr(remain, '.');
   if(postfix != NULL) {
@@ -136,7 +137,8 @@ page_static_bundle(http_connection_t *hc, const char *remain, void *opaque)
 
       http_send_header(hc, 200, content, fbe->size, 
                       fbe->original_size == -1 ? NULL : "gzip", NULL, 10);
-      write(hc->hc_fd, fbe->data, fbe->size);
+      /* ignore return value */
+      n = write(hc->hc_fd, fbe->data, fbe->size);
       return 0;
     }
   }