git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[Patch v2 2/2] strbuf: remove unreferenced strbuf_write_fd method.

From
Rrandall.s.becker@rogers.com <randall.s.becker@rogers.com>
Date
Jun 19, 2020, 20:23 UTC
Message-ID
<20200619202320.4619-3-randall.s.becker@rogers.com>
In-Reply-To
<20200619202320.4619-1-randall.s.becker@rogers.com>
From: "Randall S. Becker" <randall.becker@nexbridge.ca>

strbuf_write_fd was only used in bugreport.c. Since that file now uses write_in_full, this method is no longer needed. In addition, strbuf_write_fd did not guard against exceeding MAX_IO_SIZE for the platform, nor provided error handling in the event of a failure if only partial data was written to the file descriptor. Since already write_in_full has this capability and is in general use, it should be used instead. The change impacts strbuf.c and strbuf.h.

Signed-off-by: Randall S. Becker <rsbecker@nexbridge.com>
---
 strbuf.c | 5 -----
 strbuf.h | 1 -
 2 files changed, 6 deletions(-)
diff --git a/strbuf.c b/strbuf.c
index 2f1a7d3209..e3397cc4c7 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -556,11 +556,6 @@ ssize_t strbuf_write(struct strbuf *sb, FILE *f)
 	return sb->len ? fwrite(sb->buf, 1, sb->len, f) : 0;
 }
 
-ssize_t strbuf_write_fd(struct strbuf *sb, int fd)
-{
-	return sb->len ? write(fd, sb->buf, sb->len) : 0;
-}
-
 #define STRBUF_MAXLINK (2*PATH_MAX)
 
 int strbuf_readlink(struct strbuf *sb, const char *path, size_t hint)
diff --git a/strbuf.h b/strbuf.h
index 7062eb6410..223ee2094a 100644
--- a/strbuf.h
+++ b/strbuf.h
@@ -473,7 +473,6 @@ int strbuf_readlink(struct strbuf *sb, const char *path, size_t hint);
  * NUL bytes.
  */
 ssize_t strbuf_write(struct strbuf *sb, FILE *stream);
-ssize_t strbuf_write_fd(struct strbuf *sb, int fd);
 
 /**
  * Read a line from a FILE *, overwriting the existing contents of
-- 
2.21.0
Previous: randall.s.becker@rogers.comNext: Junio C Hamano
Message 3 of 4 in “Replace strbuf_write_fd with write_in_full”
  1. 0/2 Replace strbuf_write_fd with write_in_fullrandall.s.becker@rogers.com, Jun 19, 2020
  2. 1/2 bugreport.c: replace strbuf_write_fd with write_in_fullrandall.s.becker@rogers.com, Jun 19, 2020
  3. 2/2 strbuf: remove unreferenced strbuf_write_fd method.randall.s.becker@rogers.com, Jun 19, 2020
  4. Junio C HamanoJun 19, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.