From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754211AbbA3KO4 (ORCPT ); Fri, 30 Jan 2015 05:14:56 -0500 Received: from mga02.intel.com ([134.134.136.20]:52782 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752439AbbA3KOy (ORCPT ); Fri, 30 Jan 2015 05:14:54 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,491,1418112000"; d="scan'208";a="670217707" Message-ID: <1422612893.31903.343.camel@linux.intel.com> Subject: Re: [PATCH v2 2/3] lib/string_helpers.c: Refactor string_escape_mem From: Andy Shevchenko To: Jeff Epler Cc: Rasmus Villemoes , Andrew Morton , Mathias Krause , linux-kernel@vger.kernel.org Date: Fri, 30 Jan 2015 12:14:53 +0200 In-Reply-To: <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> <20150129193319.GB21543@unpythonic.net> Organization: Intel Finland Oy Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.12.9-1+b1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2015-01-29 at 13:33 -0600, Jeff Epler wrote: > [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 Why not inline function? > > #define addch(c) do { \ > if(out < end) *out = c; \ > ++out; \ > } while(0) > > modulo any errors or differences with standard kernel coding style. What about vsprintf.c ? -- Andy Shevchenko Intel Finland Oy