avoid logical negation operator

pull/2075/head
Gabriele Gristina 5 years ago
parent 4b9fdc6b97
commit ea786f715f

@ -442,7 +442,7 @@ static bool read_kernel_binary (hashcat_ctx_t *hashcat_ctx, const char *kernel_f
{ {
HCFILE fp; HCFILE fp;
if (hc_fopen (&fp, kernel_file, "rb") != false) if (hc_fopen (&fp, kernel_file, "rb") == true)
{ {
struct stat st; struct stat st;

@ -617,35 +617,35 @@ int _wopen(const char *path, int oflag, ...)
bool hc_fopen (HCFILE *fp, const char *path, char *mode) bool hc_fopen (HCFILE *fp, const char *path, char *mode)
{ {
if (!path || !mode) return false; if (path == NULL || mode == NULL) return false;
int oflag = -1; int oflag = -1;
int fmode = S_IRUSR|S_IWUSR; int fmode = S_IRUSR|S_IWUSR;
if (!strncmp (mode, "a", 1) || !strncmp (mode, "ab", 2)) if (strncmp (mode, "a", 1) == 0 || strncmp (mode, "ab", 2) == 0)
{ {
oflag = O_WRONLY | O_CREAT | O_APPEND; oflag = O_WRONLY | O_CREAT | O_APPEND;
#if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) #if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__)
if (!strncmp (mode, "ab", 2)) oflag |= O_BINARY; if (strncmp (mode, "ab", 2) == 0) oflag |= O_BINARY;
#endif #endif
} }
else if (!strncmp (mode, "r", 1) || !strncmp (mode, "rb", 2)) else if (strncmp (mode, "r", 1) == 0 || strncmp (mode, "rb", 2) == 0)
{ {
oflag = O_RDONLY; oflag = O_RDONLY;
fmode = -1; fmode = -1;
#if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) #if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__)
if (!strncmp (mode, "rb", 2)) oflag |= O_BINARY; if (strncmp (mode, "rb", 2) == 0) oflag |= O_BINARY;
#endif #endif
} }
else if (!strncmp (mode, "w", 1) || !strncmp (mode, "wb", 2)) else if (strncmp (mode, "w", 1) == 0 || strncmp (mode, "wb", 2) == 0)
{ {
oflag = O_WRONLY | O_CREAT | O_TRUNC; oflag = O_WRONLY | O_CREAT | O_TRUNC;
#if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) #if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__)
if (!strncmp (mode, "wb", 2)) oflag |= O_BINARY; if (strncmp (mode, "wb", 2) == 0) oflag |= O_BINARY;
#endif #endif
} }
else else
@ -686,11 +686,11 @@ bool hc_fopen (HCFILE *fp, const char *path, char *mode)
if (fp->is_gzip) if (fp->is_gzip)
{ {
if (!(fp->gfp = gzdopen (fp->fd, mode))) return false; if ((fp->gfp = gzdopen (fp->fd, mode)) == NULL) return false;
} }
else else
{ {
if (!(fp->pfp = fdopen (fp->fd, mode))) return false; if ((fp->pfp = fdopen (fp->fd, mode)) == NULL) return false;
} }
fp->path = path; fp->path = path;

Loading…
Cancel
Save