diff mbox

xen-blkback: prefer xenbus_write() over xenbus_printf() where possible

Message ID 577E299402000078000FBF24@prv-mh.provo.novell.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jan Beulich July 7, 2016, 8:06 a.m. UTC
... as being the simpler variant.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
 drivers/block/xen-blkback/xenbus.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Roger Pau Monne July 7, 2016, 9:42 a.m. UTC | #1
On Thu, Jul 07, 2016 at 02:06:12AM -0600, Jan Beulich wrote:
> ... as being the simpler variant.
> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Acked-by: Roger Pau Monné <roger.pau@citrix.com>
David Vrabel July 7, 2016, 10:26 a.m. UTC | #2
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.

David
David Vrabel July 7, 2016, 10:43 a.m. UTC | #3
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
diff mbox

Patch

--- 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));
 	if (err)
 		dev_warn(&dev->dev,
 			 "writing %s/feature-max-indirect-segments (%d)",
@@ -850,7 +850,7 @@  again:
 
 	xen_blkbk_barrier(xbt, be, be->blkif->vbd.flush_support);
 
-	err = xenbus_printf(xbt, dev->nodename, "feature-persistent", "%u", 1);
+	err = xenbus_write(xbt, dev->nodename, "feature-persistent", "1");
 	if (err) {
 		xenbus_dev_fatal(dev, err, "writing %s/feature-persistent",
 				 dev->nodename);