← Commit list

d7d683c3ba

Daniel Stenberg
Daniel Stenberg
2026-03-27
SUCCESS Duration: 272s

Subject

tool_cb_hdr: use the file descriptor instead of calling fileno() again

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

src/tool_cb_hdr.c+5 -7
@@ -266,15 +266,13 @@ static size_t save_etag(const char *etag_h, const char *endp,
curlx_struct_stat file;
int fd = fileno(etag_save->stream);
+ /* Truncate regular files to avoid stale etag content */
if((fd != -1) &&
!curlx_fstat(fd, &file) &&
- (S_ISREG(file.st_mode))) {
- /*
- * Truncate regular files to avoid stale etag content.
- */
- if(ftruncate(fileno(etag_save->stream), 0))
- return CURL_WRITEFUNC_ERROR;
- }
+ (S_ISREG(file.st_mode) &&
+ ftruncate(fd, 0)))
+ return CURL_WRITEFUNC_ERROR;
+
fwrite(etag_h, 1, etag_length, etag_save->stream);
/* terminate with newline */
fputc('\n', etag_save->stream);