From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757347AbbA2Td2 (ORCPT ); Thu, 29 Jan 2015 14:33:28 -0500 Received: from rrcs-76-79-27-186.west.biz.rr.com ([76.79.27.186]:46185 "EHLO rrcs-76-79-27-186.west.biz.rr.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757237AbbA2Td1 (ORCPT ); Thu, 29 Jan 2015 14:33:27 -0500 Date: Thu, 29 Jan 2015 13:33:19 -0600 From: Jeff Epler To: Andy Shevchenko Cc: Rasmus Villemoes , Andrew Morton , Mathias Krause , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 2/3] lib/string_helpers.c: Refactor string_escape_mem Message-ID: <20150129193319.GB21543@unpythonic.net> References: <1422451543-12401-1-git-send-email-linux@rasmusvillemoes.dk> <1422525801-26560-1-git-send-email-linux@rasmusvillemoes.dk> <1422525801-26560-3-git-send-email-linux@rasmusvillemoes.dk> <1422533541.31903.314.camel@linux.intel.com> <87sietbulp.fsf@rasmusvillemoes.dk> <1422538649.31903.330.camel@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1422538649.31903.330.camel@linux.intel.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [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