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);
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;
}
#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);
}
htsbuf_queue_t hq;
htsbuf_data_t *hd;
char *n;
+ char ok;
if(settingspath == NULL)
return;
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);
}
int fd;
char *mem;
htsmsg_t *r;
+ int n;
if(stat(filename, &st) < 0)
return NULL;
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;
}
const struct filebundle *fb = opaque;
const struct filebundle_entry *fbe;
const char *content = NULL, *postfix;
+ int n;
postfix = strrchr(remain, '.');
if(postfix != NULL) {
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;
}
}