Changeset 559


Ignore:
Timestamp:
May 20, 2006, 5:03:34 PM (13 years ago)
Author:
bcornec
Message:

strtok removed in favour of mr_strtok

File:
1 edited

Legend:

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

    r558 r559  
    10161016  FILE   *fin;
    10171017  int    res = 0, row, i, index_min;
     1018  int lastpos = 0;
    10181019  size_t len = 0;
    1019   char   *token, *string = NULL, *pos, type, *strtmp;
     1020  char   *token;
     1021  char *string = NULL;
     1022  char *pos;
     1023  char type;
     1024  char *strtmp;
    10201025
    10211026  // open file
     
    10541059    }
    10551060    // tokenise string
    1056     token = strtok (string, delims);
     1061    token = mr_strtok (string, delims, &lastpos);
    10571062    // get RAID device name
    10581063    asprintf(&strtmp,"%s%s", device_prefix, token);
    10591064    strcpy(raidlist->el[raidlist->entries].raid_device, strtmp);
    10601065    paranoid_free(strtmp);
     1066    paranoid_free(token);
    10611067    // skip ':' and status
    1062     token = strtok (NULL, delims);
    1063     token = strtok (NULL, delims);
     1068    token = strtok (string, delims, &lastpos);
     1069    paranoid_free(token);
     1070    token = strtok (string, delims, &lastpos);
    10641071    if (!strcmp(token, "inactive")) {
    10651072      log_msg(1, "RAID device '%s' inactive.\n",
    10661073         raidlist->el[raidlist->entries].raid_device);
    10671074      paranoid_free(string);
     1075      paranoid_free(token);
    10681076      return 1;
    10691077    }
     1078    paranoid_free(token);
     1079
    10701080    // get RAID level
    1071     token = strtok (NULL, delims);
     1081    token = strtok (string, delims, &lastpos);
    10721082    if (!strcmp(token, "multipath")) {
    10731083      raidlist->el[raidlist->entries].raid_level = -2;
     
    10891099      log_msg(1, "Unknown RAID level '%s'.\n", token);
    10901100      paranoid_free(string);
     1101      paranoid_free(token);
    10911102      return 1;
    10921103    }
     1104    paranoid_free(token);
     1105
    10931106    // get RAID devices (type, index, device)
    10941107    // Note: parity disk for RAID4 is last normal disk, there is no '(P)'
     
    10961109    raidlist->el[raidlist->entries].spare_disks.entries = 0;
    10971110    raidlist->el[raidlist->entries].failed_disks.entries = 0;
    1098     while((token = strtok (NULL, delims))) {
     1111    while((token = strtok (string, delims, &lastpos))) {
    10991112      if ((pos = strstr(token, "("))) {
    11001113        type = *(pos+1);
     
    11301143        log_msg(1, "Unknown device type '%c'\n", type);
    11311144        paranoid_free(string);
     1145        paranoid_free(token);
    11321146        return 1;
    11331147        break;
    11341148      }
    1135     }
     1149      paranoid_free(token);
     1150    }
     1151
    11361152    // adjust index for each device so that it starts with 0 for every type
    11371153    index_min = 99;
Note: See TracChangeset for help on using the changeset viewer.