Re: [PATCH v2 2/3] lib/string_helpers.c: Refactor string_escape_mem

From: Jeff Epler
Date: Thu Jan 29 2015 - 14:33:32 EST


[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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/