From c1a0db9f08c8cc1fa33077c38216bbe71ee4ba49 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Mon, 21 Oct 2024 08:54:40 -0400 Subject: [PATCH] MT#55283 use `fwrite` instead of `write` Change-Id: I05937db7f8268c3a87aae8793a945a0009493252 --- daemon/recording.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/daemon/recording.c b/daemon/recording.c index b4bad231b..8da7e84f0 100644 --- a/daemon/recording.c +++ b/daemon/recording.c @@ -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)); } @@ -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)); }