Ignore:
Timestamp:
Sep 20, 2013, 2:29:57 PM (6 years ago)
Author:
bruno
Message:

Simplify the interface of mr_getline and mr_asprintf. With 3.1 compatibility now will allow backports from this branch into 3.0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.0/mondo/src/common/libmondo-raid.c

    r3154 r3185  
    5151    int res;
    5252
    53     mr_asprintf(&command, "grep \"");
     53    mr_asprintf(command, "grep \"");
    5454    if (raidno == -1) {
    5555        mr_strcat(command, "linear");
     
    198198    assert(label != NULL);
    199199
    200     mr_asprintf(&sz_value, "%d", value);
     200    mr_asprintf(sz_value, "%d", value);
    201201    strcpy(raidrec->additional_vars.el[lino].label, label);
    202202    strcpy(raidrec->additional_vars.el[lino].value, sz_value);
     
    587587    fclose(fin);
    588588    log_it("Raidtab loaded successfully.");
    589     mr_asprintf(&tmp1, "%d RAID devices in raidtab", raidlist->entries);
     589    mr_asprintf(tmp1, "%d RAID devices in raidtab", raidlist->entries);
    590590    log_it(tmp1);
    591591    mr_free(tmp1);
     
    739739        }
    740740        if (!disklist) {
    741             mr_asprintf(&tmp, "Ignoring '%s %s' pair of disk %s", labelB, valueB, label);
     741            mr_asprintf(tmp, "Ignoring '%s %s' pair of disk %s", labelB, valueB, label);
    742742            log_it(tmp);
    743743            mr_free(tmp);
     
    10321032            }
    10331033            // get RAID device name
    1034             mr_asprintf(&strtmp,"%s%s", device_prefix, token);
     1034            mr_asprintf(strtmp,"%s%s", device_prefix, token);
    10351035            strncpy(raidlist->el[raidlist->entries].raid_device, strtmp, 63);
    10361036            raidlist->el[raidlist->entries].raid_device[63] = '\0';
     
    10401040            v = raidlist->el[raidlist->entries].additional_vars.entries;
    10411041            strcpy(raidlist->el[raidlist->entries].additional_vars.el[v].label, "UUID");
    1042             mr_asprintf(&cmd,"mdadm --detail %s | grep UUID | cut -d: -f2- | sed 's/^ *//'", raidlist->el[raidlist->entries].raid_device);
    1043             mr_asprintf(&strtmp, "%s", call_program_and_get_last_line_of_output(cmd));
     1042            mr_asprintf(cmd,"mdadm --detail %s | grep UUID | cut -d: -f2- | sed 's/^ *//'", raidlist->el[raidlist->entries].raid_device);
     1043            mr_asprintf(strtmp, "%s", call_program_and_get_last_line_of_output(cmd));
    10441044            strcpy(raidlist->el[raidlist->entries].additional_vars.el[v].value, strtmp);
    10451045            mr_free(strtmp);
     
    10471047            // store the Version value in the additional_vars structure
    10481048            strcpy(raidlist->el[raidlist->entries].additional_vars.el[v].label, "Version");
    1049             mr_asprintf(&cmd,"mdadm --detail %s | grep Version | cut -d: -f2- | sed 's/^ *//'", raidlist->el[raidlist->entries].raid_device);
    1050             mr_asprintf(&strtmp, "%s", call_program_and_get_last_line_of_output(cmd));
     1049            mr_asprintf(cmd,"mdadm --detail %s | grep Version | cut -d: -f2- | sed 's/^ *//'", raidlist->el[raidlist->entries].raid_device);
     1050            mr_asprintf(strtmp, "%s", call_program_and_get_last_line_of_output(cmd));
    10511051            strcpy(raidlist->el[raidlist->entries].additional_vars.el[v].value, strtmp);
    10521052            mr_free(strtmp);
     
    11281128                case ' ': // normal data disks
    11291129                    raidlist->el[raidlist->entries].data_disks.el[raidlist->el[raidlist->entries].data_disks.entries].index = atoi(pos + 1);
    1130                     mr_asprintf(&strtmp,"%s%s", device_prefix, token);
     1130                    mr_asprintf(strtmp,"%s%s", device_prefix, token);
    11311131                    strcpy(raidlist->el[raidlist->entries].data_disks.el[raidlist->el[raidlist->entries].data_disks.entries].device, strtmp);
    11321132                    mr_free(strtmp);
     
    11351135                case 'S': // spare disks
    11361136                    raidlist->el[raidlist->entries].spare_disks.el[raidlist->el[raidlist->entries].spare_disks.entries].index = atoi(pos + 1);
    1137                     mr_asprintf(&strtmp,"%s%s", device_prefix, token);
     1137                    mr_asprintf(strtmp,"%s%s", device_prefix, token);
    11381138                    strcpy(raidlist->el[raidlist->entries].spare_disks.el[raidlist->el[raidlist->entries].spare_disks.entries].device, strtmp);
    11391139                    mr_free(strtmp);
     
    11421142                case 'F': // failed disks
    11431143                    raidlist->el[raidlist->entries].failed_disks.el[raidlist->el[raidlist->entries].failed_disks.entries].index = atoi(pos + 1);
    1144                     mr_asprintf(&strtmp,"%s%s", device_prefix, token);
     1144                    mr_asprintf(strtmp,"%s%s", device_prefix, token);
    11451145                    strcpy(raidlist->el[raidlist->entries].failed_disks.el[raidlist->el[raidlist->entries].failed_disks.entries].device, strtmp);
    11461146                    mr_free(strtmp);
Note: See TracChangeset for help on using the changeset viewer.