Changeset 5747

Show
Ignore:
Timestamp:
06/30/09 22:47:53 (5 years ago)
Author:
khali
Message:

Consolidate strdup calls in sensors_get_label (patch from George Spelvin).

There were multiple in-line calls that then fell through to
a common exit. Instead, set up a pointer to the original
strings, and have a single strdup in the common code.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/trunk/lib/access.c

    r5674 r5747  
    179179                for (i = 0; i < chip->labels_count; i++) 
    180180                        if (!strcmp(feature->name, chip->labels[i].name)) { 
    181                                 label = strdup(chip->labels[i].value); 
     181                                label = chip->labels[i].value; 
    182182                                goto sensors_get_label_exit; 
    183183                        } 
     
    192192                        /* i - 1 to strip the '\n' at the end */ 
    193193                        buf[i - 1] = 0; 
    194                         label = strdup(buf); 
     194                        label = buf; 
    195195                        goto sensors_get_label_exit; 
    196196                } 
     
    198198 
    199199        /* No label, return the feature name instead */ 
    200         label = strdup(feature->name); 
     200        label = feature->name; 
    201201         
    202202sensors_get_label_exit: 
     203        label = strdup(label); 
    203204        if (!label) 
    204205                sensors_fatal_error(__func__, "Allocating label text");