[CRIU] [PATCH 1/3] util: Introduce STREQ and STRNEQ macros

Mike Rapoport rppt at linux.ibm.com
Mon Jan 28 18:03:13 MSK 2019


On Sun, Jan 27, 2019 at 10:18:57PM +0000, Radostin Stoyanov wrote:
> The function strcmp() is often used to check whether two strings are
> equal. The macros STREQ and STRNEQ could be used instead to improve
> readability of the source code.
 
> Signed-off-by: Radostin Stoyanov <rstoyanov1 at gmail.com>
> ---
>  criu/include/util.h | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/criu/include/util.h b/criu/include/util.h
> index d9a1ff0f5..427fd5105 100644
> --- a/criu/include/util.h
> +++ b/criu/include/util.h
> @@ -200,6 +200,10 @@ extern int read_fd_link(int lfd, char *buf, size_t size);
>  
>  int vaddr_to_pfn(int fd, unsigned long vaddr, u64 *pfn);
>  
> +/* String equality tests */
> +#define STREQ(a, b) (strcmp(a, b) == 0)

strcmp((a), (b))

> +#define STRNEQ(a, b) (strcmp(a, b) != 0)
> +
>  /*
>   * Check whether @str starts with @sub and report the
>   * next character of @str in @end
> -- 
> 2.20.1
> 
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu
> 

-- 
Sincerely yours,
Mike.



More information about the CRIU mailing list