On 30.03.17 18:01, Ben Peart wrote:
>> From: Torsten Bögershausen [mailto:[email protected]]
>>
>>
>> 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);
>>
> 
> 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.

Reply via email to