Fixed warn_unused_result warnings for read/write
Ignore for network io, handled for filesystem io
This commit is contained in:
parent
93418573c4
commit
4ff1113ac8
4 changed files with 29 additions and 10 deletions
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue