Skip to content

Commit

Permalink
coverity cleanup as well as fix for EUCA-9057
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Nurmi committed Apr 3, 2014
1 parent ec1c05e commit e136941
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 304 deletions.

This file was deleted.

54 changes: 26 additions & 28 deletions cluster/handlers.c
Expand Up @@ -233,7 +233,9 @@ static int populateOutboundMeta(ncMetadata * pMeta);
//!
void doInitCC(void)
{
initialize(NULL, FALSE);
if (initialize(NULL, FALSE)) {
LOGWARN("could not initialize\n");
}
}

//!
Expand Down Expand Up @@ -1601,8 +1603,6 @@ int doBroadcastNetworkInfo(ncMetadata * pMeta, char *networkInfo)
return (1);
}

sem_mywait(GLOBALNETWORKINFO);

// init the XML
xmlbuf = base64_dec((unsigned char *)networkInfo, strlen(networkInfo));
if (xmlbuf) {
Expand Down Expand Up @@ -1657,6 +1657,9 @@ int doBroadcastNetworkInfo(ncMetadata * pMeta, char *networkInfo)

EUCA_FREE(xmlbuf);
}

sem_mywait(GLOBALNETWORKINFO);

// populate globalnetworkinfo
snprintf(globalnetworkinfo->networkInfo, MAX_NETWORK_INFO, "%s", networkInfo);
config->kick_broadcast_network_info = 1;
Expand Down Expand Up @@ -4016,11 +4019,17 @@ int doRunInstances(ncMetadata * pMeta, char *amiId, char *kernelId, char *ramdis
//if (strstr(platform, "windows")) {
char cdir[EUCA_MAX_PATH];
snprintf(cdir, EUCA_MAX_PATH, EUCALYPTUS_STATE_DIR "/windows/", config->eucahome);
if (check_directory(cdir))
mkdir(cdir, 0700);
if (check_directory(cdir)) {
if(mkdir(cdir, 0700)) {
LOGWARN("mkdir failed: could not make directory '%s', check permissions\n", cdir);
}
}
snprintf(cdir, EUCA_MAX_PATH, EUCALYPTUS_STATE_DIR "/windows/%s/", config->eucahome, instId);
if (check_directory(cdir))
mkdir(cdir, 0700);
if (check_directory(cdir)) {
if (mkdir(cdir, 0700)) {
LOGWARN("mkdir failed: could not make directory '%s', check permissions\n", cdir);
}
}
if (check_directory(cdir)) {
LOGERROR("could not create console/floppy cache directory '%s'\n", cdir);
} else {
Expand Down Expand Up @@ -4371,7 +4380,10 @@ int doTerminateInstances(ncMetadata * pMeta, char **instIds, int instIdsLen, int
snprintf(cfile, EUCA_MAX_PATH, "%s/console.append.log", cdir);
if (!check_file(cfile))
unlink(cfile);
rmdir(cdir);

if (rmdir(cdir)) {
LOGWARN("rmdir failed: unable to remove directory '%s', check permissions\n", cdir);
}
}
}

Expand Down Expand Up @@ -7087,11 +7099,6 @@ int maintainNetworkState(void)
}
}

// rc = vnetApplyArpTableRules(vnetconfig);
// if (rc) {
// LOGWARN("failed to maintain arp tables\n");
// }

sem_mypost(VNET);
}

Expand Down Expand Up @@ -7262,7 +7269,9 @@ int reconfigureNetworkFromCLC(void)
EUCA_FREE(cloudIp);
return (1);
}
chmod(clcnetfile, 0644);
if (chmod(clcnetfile, 0644)) {
LOGWARN("chmod failed: was able to create tmpfile '%s', but could not change file permissions\n", clcnetfile);
}
close(fd);

fd = safe_mkstemp(chainmapfile);
Expand All @@ -7272,22 +7281,11 @@ int reconfigureNetworkFromCLC(void)
unlink(clcnetfile);
return (1);
}
chmod(chainmapfile, 0644);
if (chmod(chainmapfile, 0644)) {
LOGWARN("chmod failed: was able to create tmpfile '%s', but could not change file permissions\n", chainmapfile);
}
close(fd);

/*
fd = safe_mkstemp(config_ccfile);
if (fd < 0) {
LOGERROR("cannot open config_ccfile '%s'\n", config_ccfile);
EUCA_FREE(cloudIp);
unlink(clcnetfile);
unlink(chainmapfile);
return (1);
}
chmod(config_ccfile, 0644);
close(fd);
*/

// clcnet populate
snprintf(url, EUCA_MAX_PATH, "http://%s:8773/latest/network-topology", cloudIp);
rc = http_get_timeout(url, clcnetfile, 0, 0, 10, 15);
Expand Down
20 changes: 15 additions & 5 deletions net/ipt_handler.c
Expand Up @@ -181,7 +181,9 @@ int ipt_handler_init(ipt_handler * ipth, char *cmdprefix)
LOGERROR("cannot create tmpfile '%s': check permissions\n", ipth->ipt_file);
return (1);
}
chmod(ipth->ipt_file, 0600);
if (chmod(ipth->ipt_file, 0600)) {
LOGWARN("chmod failed: was able to create tmpfile '%s', but could not change file permissions\n", ipth->ipt_file);
}
close(fd);

if (cmdprefix) {
Expand Down Expand Up @@ -1069,7 +1071,9 @@ int ips_handler_init(ips_handler * ipsh, char *cmdprefix)
LOGERROR("cannot create tmpfile '%s': check permissions\n", ipsh->ips_file);
return (1);
}
chmod(ipsh->ips_file, 0600);
if (chmod(ipsh->ips_file, 0600)) {
LOGWARN("chmod failed: was able to create tmpfile '%s', but could not change file permissions\n", ipsh->ips_file);
}
close(fd);

if (cmdprefix) {
Expand Down Expand Up @@ -1698,7 +1702,9 @@ int ebt_handler_init(ebt_handler * ebth, char *cmdprefix)
LOGERROR("cannot create tmpfile '%s': check permissions\n", ebth->ebt_filter_file);
return (1);
}
chmod(ebth->ebt_filter_file, 0600);
if (chmod(ebth->ebt_filter_file, 0600)) {
LOGWARN("chmod failed: was able to create tmpfile '%s', but could not change file permissions\n", ebth->ebt_filter_file);
}
close(fd);

snprintf(ebth->ebt_nat_file, EUCA_MAX_PATH, "/tmp/ebt_nat_file-XXXXXX");
Expand All @@ -1707,7 +1713,9 @@ int ebt_handler_init(ebt_handler * ebth, char *cmdprefix)
LOGERROR("cannot create tmpfile '%s': check permissions\n", ebth->ebt_nat_file);
return (1);
}
chmod(ebth->ebt_nat_file, 0600);
if (chmod(ebth->ebt_nat_file, 0600)) {
LOGWARN("chmod failed: was able to create tmpfile '%s', but could not change file permissions\n", ebth->ebt_nat_file);
}
close(fd);

snprintf(ebth->ebt_asc_file, EUCA_MAX_PATH, "/tmp/ebt_asc_file-XXXXXX");
Expand All @@ -1718,7 +1726,9 @@ int ebt_handler_init(ebt_handler * ebth, char *cmdprefix)
unlink(ebth->ebt_nat_file);
return (1);
}
chmod(ebth->ebt_asc_file, 0600);
if (chmod(ebth->ebt_asc_file, 0600)) {
LOGWARN("chmod failed: was able to create tmpfile '%s', but could not change file permissions\n", ebth->ebt_asc_file);
}
close(fd);

if (cmdprefix) {
Expand Down

0 comments on commit e136941

Please sign in to comment.