From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bart Van Assche Subject: Re: [PATCH 1/2] libmultipath: print.c: make sure lines are 0-terminated Date: Wed, 17 May 2017 14:17:55 +0000 Message-ID: <1495030674.2945.4.camel@sandisk.com> References: <20170517135439.25935-1-mwilck@suse.com> <20170517135439.25935-2-mwilck@suse.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20170517135439.25935-2-mwilck@suse.com> Content-Language: en-US Content-ID: <15DAA6C3E8B4BE4CBAC39C6736D76C61@namprd04.prod.outlook.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com To: "mwilck@suse.com" , "hare@suse.de" , "christophe.varoqui@opensvc.com" Cc: "dm-devel@redhat.com" List-Id: dm-devel.ids On Wed, 2017-05-17 at 15:54 +0200, Martin Wilck wrote: > #define ENDLINE \ > - if (c > line) \ > - line[c - line - 1] = '\n' > + if (c > line) { \ > + if (c <= line + len - 1) { \ > + *(c - 1) = '\n'; \ > + *c = '\0'; \ > + } else \ > + line[len - 1] = '\0'; \ > + } Hello Martin, Please convert ENDLINE from a macro into a function. Functions are easier to maintain than macros. Thanks, Bart.