Changeset 2205


Ignore:
Timestamp:
May 14, 2009, 3:10:51 AM (11 years ago)
Author:
Bruno Cornec
Message:
  • Cleanups
  • Fix test on return value for open (-1 is the right value to test not 0)
  • Improve asprintf usage for mountlist
Location:
branches/2.2.9/mondo/src
Files:
4 edited

Legend:

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

    r2202 r2205  
    992992#if linux
    993993        fileid = open(drive, O_RDONLY);
    994         if (fileid) {
     994        if (fileid != -1) {
    995995            if (ioctl(fileid, HDIO_GETGEO, &hdgeo) != -1) {
    996996                if (hdgeo.cylinders && hdgeo.heads && hdgeo.sectors) {
  • branches/2.2.9/mondo/src/common/libmondo-mountlist.c

    r2204 r2205  
    658658        asprintf(&drive, "%s", mountlist->el[lino].device);
    659659        if (!strncmp(drive, RAID_DEVICE_STUB, strlen(RAID_DEVICE_STUB))) {
    660             log_msg(8, "Not putting %s in list of drives: it's a virtual drive",
    661                     drive);
     660            log_msg(8, "Not putting %s in list of drives: it's a virtual drive", drive);
     661            paranoid_free(drive);
    662662            continue;
    663663        }
     
    665665        size = mountlist->el[lino].size;
    666666        if (size == 0) {
    667             log_msg(8,
    668                     "Not putting %s in list of drives: it has zero size (maybe an LVM volume)",
    669                     drive);
     667            log_msg(8, "Not putting %s in list of drives: it has zero size (maybe an LVM volume)", drive);
     668            paranoid_free(drive);
    670669            continue;
    671670        }
    672671
    673         log_msg(8, "Putting %s with size %lli in list of drives",
    674                 drive, size);
     672        log_msg(8, "Putting %s with size %lli in list of drives", drive, size);
    675673
    676674        (void) truncate_to_drive_name(drive);
    677675        for (j = 0;
    678676             j < noof_drives
    679              && strcmp(drivelist->el[j].device, drive) != 0; j++)
     677             && strcmp(drivelist->el[j].device, drive) != 0; j++) {
     678            paranoid_free(drive);
    680679            continue;
     680        }
    681681        if (j == noof_drives) {
    682682            strcpy(drivelist->el[noof_drives++].device, drive);
    683683        }
     684        paranoid_free(drive);
    684685    }
    685686    drivelist->entries = noof_drives;
     
    816817        if (res < 5) {
    817818            /* no label found */
    818             asprintf(&(mountlist->el[items].label), "%s", "");
     819            asprintf(&tmp, "%s", "");
     820            mountlist->el[items].label = tmp;
    819821        }
    820822#elif __FreeBSD__
     
    824826               mountlist->el[items].mountpoint,
    825827               mountlist->el[items].format, siz);
    826         asprintf(&(mountlist->el[items].label), "%s", "");
     828        asprintf(&tmp, "%s", "");
     829        mountlist->el[items].label = tmp;
    827830#endif
    828831
  • branches/2.2.9/mondo/src/common/libmondo-tools.c

    r2195 r2205  
    13371337    int i;
    13381338    static int depth = 0;
    1339     char *tmp;
    13401339    FILE *fout;
    13411340
     
    13451344    }
    13461345    depth++;
    1347 
    1348     malloc_string(tmp);
    13491346
    13501347    if (debug_level <= g_loglevel) {
     
    13591356                fprintf(fout, "\t");
    13601357            if (getpid() == g_main_pid)
    1361                 fprintf(fout, "[Main] %s->%s#%d: ", szFile, szFunction,
    1362                         nLine);
     1358                fprintf(fout, "[Main] %s->%s#%d: ", szFile, szFunction, nLine);
    13631359            else if (getpid() == g_buffer_pid && g_buffer_pid > 0)
    1364                 fprintf(fout, "[Buff] %s->%s#%d: ", szFile, szFunction,
    1365                         nLine);
     1360                fprintf(fout, "[Buff] %s->%s#%d: ", szFile, szFunction, nLine);
    13661361            else
    1367                 fprintf(fout, "[TH=%d] %s->%s#%d: ", getpid(), szFile,
    1368                         szFunction, nLine);
     1362                fprintf(fout, "[TH=%d] %s->%s#%d: ", getpid(), szFile, szFunction, nLine);
    13691363        }
    13701364        vfprintf(fout, fmt, args);
     
    13801374    }
    13811375    depth--;
    1382     paranoid_free(tmp);
    13831376}
    13841377
  • branches/2.2.9/mondo/src/mondorestore/mondo-prep.c

    r2192 r2205  
    15961596//          if (run_program_and_log_output(tmp, TRUE)) {
    15971597            file = open(drivename, O_WRONLY);
    1598             if (!file) {
     1598            if (file != -1) {
    15991599                sprintf(tmp,
    16001600                        "Warning - unable to open %s for wiping it's partition table",
Note: See TracChangeset for help on using the changeset viewer.