Re: [PATCH v2 1/2] pkt-line: add packet_writel() and packet_read_line_gently()
- From
Torsten Bögershausen <tboegi@web.de>
- Date
- Mar 30, 2017, 17:01 UTC
- Message-ID
- <d8bb326c-6aec-9379-a5a6-051fa72f8d77@web.de>
- In-Reply-To
- <BL2PR03MB3237F4B369C0E00168D7291F4340@BL2PR03MB323.namprd03.prod.outlook.com>
On 30.03.17 18:01, Ben Peart wrote:
Show 6 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;
Typo. Should have been: packet_writel(fd, "line one", "line two", "line n", NULL);
Show 22 quoted lines
>> > > No, that's actually not valid C syntax. > >>> >>> 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. :)
Got it.