Changeset 9e093855ceddcd07647592f55ed557655b1cc24d

Show
Ignore:
Timestamp:
07/28/11 18:59:49 (3 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1311879589 -0400
git-parent:

[1921baa5ef388809bbacc4367cceb5f71ef0612c]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1311879589 -0400
Message:

last two clang warnings

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/noit_check_log.c

    r076670c r9e09385  
    350350  } 
    351351 
    352   bundle.metrics = malloc(bundle.n_metrics * sizeof(Metric*)); 
    353  
    354   // Now convert 
    355   while(noit_hash_next(&c->metrics, &iter2, &key, &klen, &vm)) { 
    356     /* If we apply the filter set and it returns false, we don't log */ 
    357     metric_t *m = (metric_t *)vm; 
    358     bundle.metrics[i] = malloc(sizeof(Metric)); 
    359     metric__init(bundle.metrics[i]); 
    360     _noit_check_log_bundle_metric(ls, bundle.metrics[i], m); 
    361     i++; 
     352  if(bundle.n_metrics > 0) { 
     353    bundle.metrics = malloc(bundle.n_metrics * sizeof(Metric*)); 
     354 
     355    // Now convert 
     356    while(noit_hash_next(&c->metrics, &iter2, &key, &klen, &vm)) { 
     357      /* If we apply the filter set and it returns false, we don't log */ 
     358      metric_t *m = (metric_t *)vm; 
     359      bundle.metrics[i] = malloc(sizeof(Metric)); 
     360      metric__init(bundle.metrics[i]); 
     361      _noit_check_log_bundle_metric(ls, bundle.metrics[i], m); 
     362      i++; 
     363    } 
    362364  } 
    363365 
  • src/noit_check_tools_shared.c

    rb553f9a r9e09385  
    138138                             char *name, int name_len, 
    139139                             char *uuid, int uuid_len) { 
     140  if(!in || len == 0) return; 
    140141  if(target) *target = '\0'; 
    141142  if(module) *module = '\0'; 
    142143  if(name) *name = '\0'; 
    143144  if(uuid) *uuid = '\0'; 
    144   if(len >= UUID_STR_LEN) { 
     145  if(uuid && len >= UUID_STR_LEN) { 
    145146    memcpy(uuid, in + len - UUID_STR_LEN, UUID_STR_LEN); 
    146147    uuid[UUID_STR_LEN] = '\0'; 
     
    153154    if(!mcp) return; 
    154155    /* copy in the target */ 
    155     if(target_len > mcp-tcp) { 
     156    if(target && target_len > mcp-tcp) { 
    156157      memcpy(target,tcp,mcp-tcp); 
    157158      target[mcp-tcp] = '\0'; 
     
    161162    if(!ncp) return; 
    162163    /* copy in the module */ 
    163     if(module_len > ncp-mcp) { 
     164    if(module && module_len > ncp-mcp) { 
    164165      memcpy(module,mcp,ncp-mcp); 
    165166      module[ncp-mcp] = '\0'; 
     
    169170    ucp = in + len - UUID_STR_LEN - 1; 
    170171    if(ncp < ucp) { 
    171       if(name_len > ucp-ncp) { 
     172      if(name && name_len > ucp-ncp) { 
    172173        memcpy(name, ncp, ucp-ncp); 
    173174        name[ucp-ncp] = '\0';