Re: [Xen-devel] [PATCH] xen-blkback: prefer xenbus_write() over xenbus_printf() where possible

From: David Vrabel
Date: Thu Jul 07 2016 - 06:43:34 EST


On 07/07/16 11:26, David Vrabel wrote:
> On 07/07/16 09:06, Jan Beulich wrote:
>> ... as being the simpler variant.
> [...]
>> --- 4.7-rc6-prefer-xenbus_write.orig/drivers/block/xen-blkback/xenbus.c
>> +++ 4.7-rc6-prefer-xenbus_write/drivers/block/xen-blkback/xenbus.c
>> @@ -617,9 +617,9 @@ static int xen_blkbk_probe(struct xenbus
>> goto fail;
>> }
>>
>> - err = xenbus_printf(XBT_NIL, dev->nodename,
>> - "feature-max-indirect-segments", "%u",
>> - MAX_INDIRECT_SEGMENTS);
>> + err = xenbus_write(XBT_NIL, dev->nodename,
>> + "feature-max-indirect-segments",
>> + __stringify(MAX_INDIRECT_SEGMENTS));
>
> Yuk :(
>
> Now someone has to check both __stringify() and MAX_INDIRECT_SEGMENTS to
> work out what this actually looks like.

In particular, if we ended up with

#define MAX_INDIRECT_SEGMENTS 512u

or similar then the code is now wrong.

David