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

Re: [PATCH] implemented strbuf_write_or_die()

From
Johannes Sixt <j6t@kdbg.org>
Date
Mar 1, 2014, 21:34 UTC
Message-ID
<53125266.8040007@kdbg.org>
In-Reply-To
<1393672871-28281-1-git-send-email-faiz.off93@gmail.com>
Am 01.03.2014 12:21, schrieb Faiz Kothari:
Show 7 quoted lines
> Signed-off-by: Faiz Kothari <faiz.off93@gmail.com>
> ---
> Implemented write_or_die.c:strbuf_write_or_die() and used in relevant places
> to substitute write_or_die(). I spotted other places where strbuf can be used
> in place of buf[MAX_PATH] but that would require a change in prototype of a 
> lot of functions and functions calling them and so on....
> I'll look for more places where strbuf can be used safely.
You haven't given a justifiction of the change (why is this change good?)
Show 7 quoted lines
> diff --git a/write_or_die.c b/write_or_die.c
> index b50f99a..5fb309b 100644
> --- a/write_or_die.c
> +++ b/write_or_die.c
> @@ -1,4 +1,5 @@
>  #include "cache.h"
> +#include "strbuf.h"

I think you have the layering backwards here: strbuf_write_or_die should be part of the (higher-level) strbuf API, and not an extension of the low-level write_or_die function.

Show 8 quoted lines
>  
>  static void check_pipe(int err)
>  {
> @@ -64,6 +65,14 @@ void write_or_die(int fd, const void *buf, size_t count)
>  	}
>  }
>  
> +void strbuf_write_or_die(int fd, const struct strbuf *sbuf)
And when you make the function a strbuf API, the prototype should be
void strbuf_write_or_die(const struct strbuf *sbuf, int fd)
as in "hey, strbuf object, write your content to this file descriptor!"
Show 11 quoted lines
> +{
> +	if(write_in_full(fd, sbuf->buf, sbuf->len) < 0){
> +		check_pipe(errno);
> +		die_errno("write error");
> +	}
> +}
> +
>  int write_or_whine_pipe(int fd, const void *buf, size_t count, const char *msg)
>  {
>  	if (write_in_full(fd, buf, count) < 0) {
> 
-- Hannes
Previous: Junio C HamanoNext: Junio C Hamano
Message 21 of 23 in “implemented strbuf_write_or_die()”
  1. implemented strbuf_write_or_die()Faiz Kothari, Mar 1, 2014
  2. He SunMar 1, 2014
  3. implemented strbuf_write_or_die()Faiz Kothari, Mar 1, 2014
  4. Michael HaggertyMar 1, 2014
  5. implemented strbuf_write_or_die()Faiz Kothari, Mar 2, 2014
  6. Eric SunshineMar 2, 2014
  7. Eric SunshineMar 2, 2014
  8. 1/2 Introduce strbuf_write_or_die()Faiz Kothari, Mar 2, 2014
  9. 2/2 use strbuf_write_or_die()Faiz Kothari, Mar 2, 2014
  10. Eric SunshineMar 2, 2014
  11. Eric SunshineMar 2, 2014
  12. Eric SunshineMar 2, 2014
  13. Junio C HamanoMar 3, 2014
  14. Eric SunshineMar 3, 2014
  15. David KastrupMar 3, 2014
  16. Junio C HamanoMar 3, 2014
  17. Eric SunshineMar 3, 2014
  18. Michael HaggertyMar 4, 2014
  19. Faiz KothariMar 4, 2014
  20. Junio C HamanoMar 4, 2014
  21. Johannes SixtMar 1, 2014
  22. Junio C HamanoMar 3, 2014
  23. Fwd: [PATCH] implemented strbuf_write_or_die()Faiz Kothari, Mar 3, 2014

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.