X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fhelper%2Foptions.c;h=327c418d0db9fa5b2d37f7d7b86f8aae8e718593;hb=382148e4dd437978997d668f6ec715ddcec1c46e;hp=f996749ea88bace77de5e2b830edd3857cb9a6ea;hpb=87c90393fedc8bb278d189aa53bcd93f4892012b;p=fw%2Fopenocd diff --git a/src/helper/options.c b/src/helper/options.c index f996749ea..327c418d0 100644 --- a/src/helper/options.c +++ b/src/helper/options.c @@ -1,22 +1,11 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + /*************************************************************************** * Copyright (C) 2004, 2005 by Dominic Rath * * Dominic.Rath@gmx.de * * * * Copyright (C) 2007-2010 Øyvind Harboe * * oyvind.harboe@zylin.com * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program. If not, see . * ***************************************************************************/ #ifdef HAVE_CONFIG_H @@ -75,7 +64,7 @@ static char *find_exe_path(void) do { #if IS_WIN32 && !IS_CYGWIN exepath = malloc(MAX_PATH); - if (exepath == NULL) + if (!exepath) break; GetModuleFileName(NULL, exepath, MAX_PATH); @@ -87,7 +76,7 @@ static char *find_exe_path(void) #elif IS_DARWIN exepath = malloc(PROC_PIDPATHINFO_MAXSIZE); - if (exepath == NULL) + if (!exepath) break; if (proc_pidpath(getpid(), exepath, PROC_PIDPATHINFO_MAXSIZE) <= 0) { free(exepath); @@ -99,7 +88,7 @@ static char *find_exe_path(void) #define PATH_MAX 1024 #endif char *path = malloc(PATH_MAX); - if (path == NULL) + if (!path) break; int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 }; size_t size = PATH_MAX; @@ -117,14 +106,14 @@ static char *find_exe_path(void) #elif defined(HAVE_REALPATH) /* Assume POSIX.1-2008 */ /* Try Unices in order of likelihood. */ exepath = realpath("/proc/self/exe", NULL); /* Linux/Cygwin */ - if (exepath == NULL) + if (!exepath) exepath = realpath("/proc/self/path/a.out", NULL); /* Solaris */ - if (exepath == NULL) + if (!exepath) exepath = realpath("/proc/curproc/file", NULL); /* FreeBSD (Should be covered above) */ #endif } while (0); - if (exepath != NULL) { + if (exepath) { /* Strip executable file name, leaving path */ *strrchr(exepath, '/') = '\0'; } else { @@ -163,7 +152,7 @@ static char *find_relative_path(const char *from, const char *to) if (from[0] != '/') i++; char *next = strchr(from, '/'); - if (next == NULL) + if (!next) break; from = next + 1; }