[dm-devel] [PATCH 1/2] libmultipath: print.c: make sure lines are 0-terminated

Bart Van Assche Bart.VanAssche at sandisk.com
Wed May 17 14:17:55 UTC 2017


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.




More information about the dm-devel mailing list