RE: [PATCH v2 1/2] pkt-line: add packet_writel() and packet_read_line_gently()
Show 7 quoted lines
> From: Torsten Bögershausen [mailto:tboegi@web.de]
>
>
> Does this work ?
> I would have expected
> packet_writel(fd, "line one", "line two", "line n"), NULL;
>
No, that's actually not valid C syntax.
Show 11 quoted lines
> >
> > which requires the use of variable number of arguments. With your
> proposal that convenience is lost as you have to create an array of strings
> and pass that instead. The usage just isn't as simple as the current model.
> >
> What is wrong with
>
> int packet_write_fmt_gently(int fd, const char *fmt, ...) and we use it like
> this:
> if packet_write_fmt_gently(fd, "%s%s%s", "line one", "line two", "line n")
>
Packets are not just strings; see pkt-line.h for more details but basically they are a length packet, followed by the data (in this particular case a string). The packet_writel function is a convenience function to write out a variable number of packetized strings followed by a flush packet. You're sample above would simply concatenate the three strings and then write a single packet. A very different outcome. :)
Show 6 quoted lines
>
>
> (Or do we need another one like)
> int packet_write_fmt_gently_flush(int fd, const char *fmt, ...)
>
> Sorry if I am lost here