Ignore:
Timestamp:
Jun 3, 2009, 7:10:19 PM (15 years ago)
Author:
Bruno Cornec
Message:

r3089@localhost: bruno | 2009-05-18 06:41:05 +0200

  • move call to asprintf to call to mr_asprintf (suppress a compiler warning)
  • remove all the most obvious bad call to strcat and replace by mr_strcat as appropriate
File:
1 edited

Legend:

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

    r2190 r2211  
    11/* libmondo-raid.c                                                subroutines for handling RAID
    22   $Id$
    3 .
    4 
    5 
    6 06/29
    7 - added create_raidtab_from_mdstat()
    8 - changed char[MAX_STR_LEN] to char*
    9 
    10 10/21/2003
    11 - get_next_raidtab_line() --- correctly handle multiple spaces
    12   between label and value
    13 
    14 07/03
    15 - line 447 - changed assert()
    16 
    17 05/08
    18 - cleaned up some FreeBSd-specific stuff
    19 
    20 05/05
    21 - added Joshua Oreman's FreeBSD patches
    22 
    23 04/25
    24 - added a bunch of RAID utilities from mondorestore/mondo-restore.c
    25 
    26 04/24/2003
    27 - added some assert()'s and log_OS_error()'s
    28 
    29 10/19/2002
    30 - added some comments
    31 
    32 07/24
    33 - created
    343*/
    354
     
    4918#include "libmondo-raid.h"
    5019#include "mr_string.h"
     20#include "mr_mem.h"
    5121
    5222#ifdef __FreeBSD__
     
    7747#else
    7848    /*@ buffer ********************************************************** */
    79     char *command;
     49    char *command = NULL;
    8050    int res;
    8151
    82     command = malloc(MAX_STR_LEN * 2);
    83     strcpy(command, "grep \"");
     52    mr_asprintf(&command, "grep \"");
    8453    if (raidno == -1) {
    85         strcat(command, "linear");
     54        mr_strcat(command, "linear");
    8655    } else {
    87         sprintf(command + strlen(command), "raid%d", raidno);
    88     }
    89     strcat(command, "\" /proc/mdstat > /dev/null 2> /dev/null");
     56        mr_strcat(command, "raid%d", raidno);
     57    }
     58    mr_strcat(command, "\" /proc/mdstat > /dev/null 2> /dev/null");
    9059    log_it("Is raid %d registered? Command = '%s'", raidno, command);
    9160    res = system(command);
    9261    paranoid_free(command);
     62
    9363    if (res) {
    9464        return (FALSE);
     
    10431013    pos = string;
    10441014    while (*pos == ' ') pos += 1;
    1045     asprintf(&strtmp, "%s", pos);
     1015    mr_asprintf(&strtmp, "%s", pos);
    10461016    strcpy(string, strtmp);
    10471017    paranoid_free(strtmp);
     
    10641034    token = mr_strtok (string, delims, &lastpos);
    10651035    // get RAID device name
    1066     asprintf(&strtmp,"%s%s", device_prefix, token);
     1036    mr_asprintf(&strtmp,"%s%s", device_prefix, token);
    10671037    strcpy(raidlist->el[raidlist->entries].raid_device, strtmp);
    10681038    paranoid_free(strtmp);
     
    11231093      case ' ': // normal data disks
    11241094        raidlist->el[raidlist->entries].data_disks.el[raidlist->el[raidlist->entries].data_disks.entries].index = atoi(pos + 1);
    1125         asprintf(&strtmp,"%s%s", device_prefix, token);
     1095        mr_asprintf(&strtmp,"%s%s", device_prefix, token);
    11261096        strcpy(raidlist->el[raidlist->entries].data_disks.el[raidlist->el[raidlist->entries].data_disks.entries].device, strtmp);
    11271097        paranoid_free(strtmp);
     
    11301100      case 'S': // spare disks
    11311101        raidlist->el[raidlist->entries].spare_disks.el[raidlist->el[raidlist->entries].spare_disks.entries].index = atoi(pos + 1);
    1132         asprintf(&strtmp,"%s%s", device_prefix, token);
     1102        mr_asprintf(&strtmp,"%s%s", device_prefix, token);
    11331103        strcpy(raidlist->el[raidlist->entries].spare_disks.el[raidlist->el[raidlist->entries].spare_disks.entries].device, strtmp);
    11341104        paranoid_free(strtmp);
     
    11371107      case 'F': // failed disks
    11381108        raidlist->el[raidlist->entries].failed_disks.el[raidlist->el[raidlist->entries].failed_disks.entries].index = atoi(pos + 1);
    1139         asprintf(&strtmp,"%s%s", device_prefix, token);
     1109        mr_asprintf(&strtmp,"%s%s", device_prefix, token);
    11401110        strcpy(raidlist->el[raidlist->entries].failed_disks.el[raidlist->el[raidlist->entries].failed_disks.entries].device, strtmp);
    11411111        paranoid_free(strtmp);
Note: See TracChangeset for help on using the changeset viewer.