From: Christian Brauner Date: Sat, 13 Feb 2021 20:35:01 +0000 (+0100) Subject: file_utils: convert to strequal() X-Git-Tag: lxc-5.0.0~290^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b3fde94479a8acb1263eded3bab7867ff0819009;p=thirdparty%2Flxc.git file_utils: convert to strequal() Signed-off-by: Christian Brauner --- diff --git a/src/lxc/file_utils.c b/src/lxc/file_utils.c index 78fa85ed7..508e2a5bb 100644 --- a/src/lxc/file_utils.c +++ b/src/lxc/file_utils.c @@ -363,22 +363,22 @@ FILE *fopen_cloexec(const char *path, const char *mode) int open_mode = 0, step = 0; FILE *f; - if (!strncmp(mode, "r+", 2)) { + if (strnequal(mode, "r+", 2)) { open_mode = O_RDWR; step = 2; - } else if (!strncmp(mode, "r", 1)) { + } else if (strnequal(mode, "r", 1)) { open_mode = O_RDONLY; step = 1; - } else if (!strncmp(mode, "w+", 2)) { + } else if (strnequal(mode, "w+", 2)) { open_mode = O_RDWR | O_TRUNC | O_CREAT; step = 2; - } else if (!strncmp(mode, "w", 1)) { + } else if (strnequal(mode, "w", 1)) { open_mode = O_WRONLY | O_TRUNC | O_CREAT; step = 1; - } else if (!strncmp(mode, "a+", 2)) { + } else if (strnequal(mode, "a+", 2)) { open_mode = O_RDWR | O_CREAT | O_APPEND; step = 2; - } else if (!strncmp(mode, "a", 1)) { + } else if (strnequal(mode, "a", 1)) { open_mode = O_WRONLY | O_CREAT | O_APPEND; step = 1; }