]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Fix Misc. issues in vmtoolsLog.c
authorOliver Kurth <okurth@vmware.com>
Mon, 9 Sep 2019 18:23:49 +0000 (11:23 -0700)
committerOliver Kurth <okurth@vmware.com>
Mon, 9 Sep 2019 18:23:49 +0000 (11:23 -0700)
* g_malloc0 aborts the application if the specificed amount of memory
  cannot be allocated. Hence, no need to have a NULL check for the
  return value of g_malloc0.

* Removed one if block in VMToolsLogInt since the if check will never
  be TRUE.

* g_strdup returns NULL if the input argument is NULL. Removed
  the unnecessary NULL checks for the input argument to g_strdup at few
  places.

open-vm-tools/libvmtools/vmtoolsLog.c

index 6c83f7646027f70deb7514a8bc1220fa2b7812d0..3259d84ca454d001b37a58e275c51ad7b885f59d 100644 (file)
@@ -610,14 +610,9 @@ VMToolsLogInt(const gchar *domain,
       data = data->inherited ? gDefaultData : data;
 
       entry = g_malloc0(sizeof(LogEntry));
-      if (entry) {
-         entry->domain = domain ? g_strdup(domain) : NULL;
-         if (domain && !entry->domain) {
-            VMToolsLogPanic();
-         }
-         entry->handler = data;
-         entry->level = level;
-      }
+      entry->domain = g_strdup(domain);
+      entry->handler = data;
+      entry->level = level;
 
       if (gLogIOSuspended && data->needsFileIO) {
          if (gMaxCacheEntries == 0) {
@@ -1016,7 +1011,7 @@ VMToolsGetLogHandler(const gchar *handler,
    logger->type = strdup(handler);
    logger->needsFileIO = needsFileIO;
    logger->isSysLog = isSysLog;
-   logger->confData = (path != NULL ? g_strdup(path) : NULL);
+   logger->confData = g_strdup(path);
    g_free(path);
 
    return logger;