diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/openlmi.c | 16 | ||||
-rw-r--r-- | src/openlmi.h | 10 |
2 files changed, 24 insertions, 2 deletions
diff --git a/src/openlmi.c b/src/openlmi.c index 786bdd2..c6d808e 100644 --- a/src/openlmi.c +++ b/src/openlmi.c @@ -34,11 +34,19 @@ static int _log_level = _LMI_DEBUG_DEBUG; static const CMPIBroker *_cb = NULL; static char *_log_id = NULL; +/** Gets Fully Quantified Domain Name of the system + * @return FQDN (must be freed by the caller) + */ static char *getFQDN(void) { struct utsname uts; - if ((uname(&uts) > 0) && (uts.nodename != NULL)) { - return strdup(uts.nodename); + if ((uname(&uts) > 0) && (strlen(uts.nodename) > 0)) { + char *nodename; + if ((nodename = strdup(uts.nodename)) == NULL) { + lmi_error("Memory allocation failed"); + return NULL; + } + return nodename; } char hostname[256]; hostname[255] = '\0'; @@ -59,6 +67,10 @@ static char *getFQDN(void) if (p->ai_canonname && strstr(p->ai_canonname, "localhost") == NULL) { char *dn = strdup(p->ai_canonname); freeaddrinfo(info); + if (dn == NULL) { + lmi_error("Memory allocation failed"); + return NULL; + } return dn; } } diff --git a/src/openlmi.h b/src/openlmi.h index 9b27d07..6ab4158 100644 --- a/src/openlmi.h +++ b/src/openlmi.h @@ -65,6 +65,16 @@ int lmi_log_level(void); */ void lmi_set_log_level(int level); +/** + * Add an instance \p w to the result \p cr. + * + * @param cr CMPIResult where should be the instance added + * @param w instance to add + * @retval true if succeeds + * @retval false if addition fails + */ +#define LMI_ReturnInstance(cr, w) KOkay(__KReturnInstance((cr), &(w).__base)) + enum { _LMI_DEBUG_NONE=0, _LMI_DEBUG_ERROR, _LMI_DEBUG_WARN, _LMI_DEBUG_INFO, _LMI_DEBUG_DEBUG |