openocd: fix simple cases of NULL comparison

There are more than 1000 NULL comparisons to be aligned to the
coding style.
For recurrent NULL comparison it's preferable using trivial
scripts in order to minimize the review effort.

Patch generated automatically with the command:
	sed -i PATTERN $(find src/ -type f)
where PATTERN is in the list:
	's/(\([a-z][a-z0-9_]*\) == NULL)/(!\1)/g'
	's/(\([a-z][a-z0-9_]*->[a-z][a-z0-9_]*\) == NULL)/(!\1)/g'
	's/(\([a-z][a-z0-9_]*\.[a-z][a-z0-9_]*\) == NULL)/(!\1)/g'

	's/(\([a-z][a-z0-9_]*\) != NULL)/(\1)/g'
	's/(\([a-z][a-z0-9_]*->[a-z][a-z0-9_]*\) != NULL)/(\1)/g'
	's/(\([a-z][a-z0-9_]*\.[a-z][a-z0-9_]*\) != NULL)/(\1)/g'

	's/(NULL == \([a-z][a-z0-9_]*\))/(!\1)/g'
	's/(NULL == \([a-z][a-z0-9_]*->[a-z][a-z0-9_]*\))/(!\1)/g'
	's/(NULL == \([a-z][a-z0-9_]*\.[a-z][a-z0-9_]*\))/(!\1)/g'

	's/(NULL != \([a-z][a-z0-9_]*\))/(\1)/g'
	's/(NULL != \([a-z][a-z0-9_]*->[a-z][a-z0-9_]*\))/(\1)/g'
	's/(NULL != \([a-z][a-z0-9_]*\.[a-z][a-z0-9_]*\))/(\1)/g'

Change-Id: Ida103e325d6d0600fb69c0b7a1557ee969db4417
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6350
Tested-by: jenkins
This commit is contained in:
Antonio Borneo
2021-07-03 18:51:20 +02:00
parent b159f5cded
commit 08ee7bb982
166 changed files with 856 additions and 856 deletions

View File

@@ -75,7 +75,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 +87,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 +99,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 +117,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 +163,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;
}