Skip to content

Commit

Permalink
MT#55283 use fwrite instead of write
Browse files Browse the repository at this point in the history
Change-Id: I05937db7f8268c3a87aae8793a945a0009493252
  • Loading branch information
rfuchs committed Oct 21, 2024
1 parent d728233 commit c1a0db9
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions daemon/recording.c
Original file line number Diff line number Diff line change
Expand Up @@ -532,10 +532,6 @@ static void sdp_after_pcap(struct recording *recording, const str *s, struct cal
if (!meta_fp)
return;

int meta_fd = fileno(meta_fp);
// File pointers buffer data, whereas direct writing using the file
// descriptor does not. Make sure to flush any unwritten contents
// so the file contents appear in order.
if (ml->label.len) {
fprintf(meta_fp, "\nLabel: " STR_FORMAT, STR_FMT(&ml->label));
}
Expand All @@ -544,8 +540,7 @@ static void sdp_after_pcap(struct recording *recording, const str *s, struct cal
fprintf(meta_fp, "\nSDP mode: ");
fprintf(meta_fp, "%s", get_opmode_text(opmode));
fprintf(meta_fp, "\nSDP before RTP packet: %" PRIu64 "\n\n", recording->pcap.packet_num);
fflush(meta_fp);
if (write(meta_fd, s->s, s->len) <= 0)
if (fwrite(s->s, s->len, 1, meta_fp) < 1)
ilog(LOG_WARN, "Error writing SDP body to metadata file: %s", strerror(errno));
}

Expand Down

0 comments on commit c1a0db9

Please sign in to comment.