Merge "fix compilation warnings in c/cpp files"

This commit is contained in:
Zuul 2018-10-30 02:37:06 +00:00 committed by Gerrit Code Review
commit e472f51aed
6 changed files with 23 additions and 17 deletions

View File

@ -761,11 +761,6 @@ int httpUtil_api_request ( libEvent & event )
{
;
}
else if ( TEST_WITH_NO_TOKEN )
{
;
}
else
{
slog ("%s Unsupported Request (%d)\n", event.hostname.c_str(), event.request);

View File

@ -158,9 +158,6 @@ typedef enum {
KEYSTONE_GET_SERVICE_LIST,
KEYSTONE_GET_ENDPOINT_LIST,
TEST_WITH_NO_TOKEN,
TEST_WITH_TOKEN,
SERVICE_LAST
} libEvent_enum ;

View File

@ -309,10 +309,13 @@ int msgClassAddr::getAddressFromInterface(const char* interface, char* address,
// if it is infra then we need to determine the interface
// host name. For management interface, the system hostname
// is the intf hostname
char iface_hostname[MAX_HOST_NAME_SIZE+1] = {0};
snprintf(iface_hostname, MAX_HOST_NAME_SIZE,
const char* infra_suffix = "-infra";
size_t infra_suffix_len = sizeof(infra_suffix);
char iface_hostname[MAX_HOST_NAME_SIZE+infra_suffix_len];
memset(iface_hostname, 0, sizeof(iface_hostname));
snprintf(iface_hostname, sizeof(iface_hostname),
"%s%s", hostname,
(((interface_type == INFRA_IFACE)) ? "-infra" : ""));
(((interface_type == INFRA_IFACE)) ? infra_suffix : ""));
struct addrinfo *res = NULL;
int ret = getaddrinfo(iface_hostname, NULL, NULL, &res);

View File

@ -630,7 +630,7 @@ int get_iface_macaddr ( const char * iface_ptr , string & macaddr )
char str [COL_CHARS_IN_MAC_ADDR+1] ; /* and terminator */
memset ( &str[0], 0 , COL_CHARS_IN_MAC_ADDR);
snprintf ( &str[0], COL_CHARS_IN_MAC_ADDR+1,
snprintf ( &str[0], sizeof(str),
"%02x:%02x:%02x:%02x:%02x:%02x",
(unsigned char)(s.ifr_hwaddr.sa_data[0]),
(unsigned char)(s.ifr_hwaddr.sa_data[1]),
@ -665,7 +665,7 @@ string get_iface_mac ( const char * iface_ptr )
char str [COL_CHARS_IN_MAC_ADDR+1] ; /* and terminator */
memset ( &str[0], 0 , COL_CHARS_IN_MAC_ADDR);
snprintf ( &str[0], COL_CHARS_IN_MAC_ADDR,
snprintf ( &str[0], sizeof(str),
"%02x:%02x:%02x:%02x:%02x:%02x",
(unsigned char)(s.ifr_hwaddr.sa_data[0]),
(unsigned char)(s.ifr_hwaddr.sa_data[1]),

View File

@ -777,7 +777,16 @@ string get_shadow_signature ( char * shadowfile , const char * username,
continue;
}
char shadowEntry[BUFFER] = {0};
/* at max, both password[] and aging[] include BUFFER chars (BUFFER-1
* meaningful chars and one "\0" as tail). when they are combined with
* ":" and put into shadowEntry by snprintf (..., "%s:%s", ...),
* shadowEntry has 2 chars (":" + "\0") at least and BUFFER*2 chars at most:
* BUFFER-1 chars copied from password
* ":"
* BUFFER-1 chars copied from aging, and
* one tail "\0"
*/
char shadowEntry[BUFFER*2] = {0};
snprintf (shadowEntry, sizeof(shadowEntry),
"%s:%s", password, aging);
@ -931,8 +940,10 @@ void daemon_rename_file ( const char * path, const char * old_filename, const ch
void daemon_remove_pidfile ( void )
{
char str [64] ;
sprintf (str, "rm -f %s", pid_filename );
const char* cmd_str = "rm -f ";
size_t cmd_len = sizeof(cmd_str);
char str [MAX_FILENAME_LEN+cmd_len] ;
snprintf (str, sizeof(str), "rm -f %s", pid_filename);
int rc = system (str);
if ( rc )
{

View File

@ -56,7 +56,7 @@ static char* find_char_or_comment(const char* s, char c)
/* Version of strncpy that ensures dest (size bytes) is null-terminated. */
static char* strncpy0(char* dest, const char* src, size_t size)
{
strncpy(dest, src, size);
strncpy(dest, src, size-1);
dest[size - 1] = '\0';
return dest;
}