lkml.org 
[lkml]   [2013]   [Aug]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 2/2] aoe: use min() to simplify the code
Date
min() incorporates condition in it. In our case we could do assignment and
make a choice at once.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/block/aoe/aoedev.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/block/aoe/aoedev.c b/drivers/block/aoe/aoedev.c
index db35ef6..92fadfa 100644
--- a/drivers/block/aoe/aoedev.c
+++ b/drivers/block/aoe/aoedev.c
@@ -13,6 +13,7 @@
#include <linux/kdev_t.h>
#include <linux/moduleparam.h>
#include <linux/string.h>
+#include <linux/kernel.h>
#include "aoe.h"

static void dummy_timer(ulong);
@@ -248,10 +249,7 @@ user_req(char *s, size_t slen, struct aoedev *d)
if (!d->gd)
return 0;
p = kbasename(d->gd->disk_name);
- lim = sizeof(d->gd->disk_name);
- lim -= p - d->gd->disk_name;
- if (slen < lim)
- lim = slen;
+ lim = min(sizeof(d->gd->disk_name) - (p - d->gd->disk_name), slen);

return !strncmp(s, p, lim);
}
--
1.8.3.2


\
 
 \ /
  Last update: 2013-08-01 14:41    [W:0.041 / U:0.312 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site