Skip to contentSkip to conversation

sunrpc/cache: simplify qword_add

PATCH New Andy Shevchenko 1 participant 1 message Mar 6, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 sunrpc/cache: simplify qword_add

The commit 7572d3b29896 (lib/string_helpers.c: change semantics of string_escape_mem) updates qword_add() to follow the changes in lib/string_helpers.c. This patch simplifies the approach.

---
Andrew, I think this one can be folded in the mentioned commit by Rasmus. Changelog v2:
- add missed curly braces (grr... I have them in initial comment)

 net/sunrpc/cache.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
net/sunrpc/cache.c +5 -5
index 22c4418..ba815df 100644
@@ -1068,16 +1068,16 @@ void qword_add(char **bpp, int *lp, char *str)
 {
 	char *bp = *bpp;
 	int len = *lp;
-	int ret, written;
+	int ret;
 
 	if (len < 0) return;
 
 	ret = string_escape_str(str, bp, len, ESCAPE_OCTAL, "\\ \n\t");
-	written = min(ret, len);
-	bp += written;
-	if (ret >= len)
+	if (ret >= len) {
+		bp += len;
 		len = -1;
-	else {
+	} else {
+		bp += ret;
 		len -= ret;
 		*bp++ = ' ';
 		len--;
Signature · 1 line
2.1.4