lkml.org 
[lkml]   [2015]   [Jan]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 2/3] lib/string_helpers.c: Refactor string_escape_mem
[discussing the repeated three-line idiom]
> if (out < end)
> *out = '\\';
> ++out;

Instead of open-coding this each time, perhaps it would be appropriate
to define a macro to possibly put a character and also advance the
pointer.

Assuming that the locals are consistently "out" and "end", something
like

#define addch(c) do { \
if(out < end) *out = c; \
++out; \
} while(0)

modulo any errors or differences with standard kernel coding style.

Jeff


\
 
 \ /
  Last update: 2015-01-29 20:41    [W:0.099 / U:0.080 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site