Ignore:
Timestamp:
May 13, 2009, 4:34:00 AM (15 years ago)
Author:
Bruno Cornec
Message:
  • Remove useless function look_for_weird_formats
  • Adds a test program for mountlist management to find a seg. fault bug when using a large mountlist file
File:
1 edited

Legend:

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

    r2201 r2202  
    440440    }
    441441    malloc_string(tmp);
    442     for (fgets(tmp, MAX_STR_LEN, pattr); !feof(pattr);
    443          fgets(tmp, MAX_STR_LEN, pattr)) {
     442    for ((void)fgets(tmp, MAX_STR_LEN, pattr); !feof(pattr);
     443         (void)fgets(tmp, MAX_STR_LEN, pattr)) {
    444444        fputs(tmp, pout);
    445445    }
     
    476476    }
    477477    malloc_string(file_to_analyze);
    478     for (fgets(file_to_analyze, MAX_STR_LEN, fin); !feof(fin);
    479          fgets(file_to_analyze, MAX_STR_LEN, fin)) {
     478    for ((void)fgets(file_to_analyze, MAX_STR_LEN, fin); !feof(fin);
     479         (void)fgets(file_to_analyze, MAX_STR_LEN, fin)) {
    480480        i = strlen(file_to_analyze);
    481481        if (i > 0 && file_to_analyze[i - 1] < 32) {
     
    484484        log_msg(8, "Analyzing %s", file_to_analyze);
    485485        tmp = mr_stresc(file_to_analyze, "`$\\\"()\'|", '\\');
    486         asprintf(&strtmp, syscall_sprintf, tmp);
     486        (void)asprintf(&strtmp, syscall_sprintf, tmp);
    487487        paranoid_free(tmp);
    488         asprintf(&syscall, "%s 2>> /dev/null", strtmp); // " MONDO_LOGFILE);
     488        (void)asprintf(&syscall, "%s 2>> /dev/null", strtmp);   // " MONDO_LOGFILE);
    489489        paranoid_free(strtmp);
    490490        call_exe_and_pipe_output_to_fd(syscall, pout);
     
    609609//  printf("Hi there. Starting the loop\n");
    610610
    611     fgets(current_subset_file, MAX_STR_LEN, faclin);
    612     fgets(incoming, MAX_STR_LEN, pin);
     611    (void)fgets(current_subset_file, MAX_STR_LEN, faclin);
     612    (void)fgets(incoming, MAX_STR_LEN, pin);
    613613    while (!feof(pin) && !feof(faclin)) {
    614614//      printf("incoming = %s", incoming);
     
    642642        if (i < 0) {            // read another subset file in.
    643643            log_msg(my_depth, "Reading next subset line in\n\n");
    644             fgets(current_subset_file, MAX_STR_LEN, faclin);
     644            (void)fgets(current_subset_file, MAX_STR_LEN, faclin);
    645645            continue;
    646646        }
     
    649649            fputs(incoming, pout);
    650650        }
    651         fgets(incoming, MAX_STR_LEN, pin);
     651        (void)fgets(incoming, MAX_STR_LEN, pin);
    652652        if (!i) {
    653653            log_msg(my_depth, "Copying master %s", q);
     
    662662                fputs(incoming, pout);
    663663            }
    664             fgets(incoming, MAX_STR_LEN, pin);
     664            (void)fgets(incoming, MAX_STR_LEN, pin);
    665665        }
    666666        if (!i) {
    667             fgets(current_subset_file, MAX_STR_LEN, faclin);
     667            (void)fgets(current_subset_file, MAX_STR_LEN, faclin);
    668668        }
    669669    }
    670670    while (!feof(pin)) {
    671         fgets(incoming, MAX_STR_LEN, pin);
     671        (void)fgets(incoming, MAX_STR_LEN, pin);
    672672    }
    673673    fclose(faclin);
     
    916916    }
    917917    open_evalcall_form("Loading filelist from disk");
    918     for (fgets(fname, MAX_STR_LEN, pin); !feof(pin);
    919          fgets(fname, MAX_STR_LEN, pin)) {
     918    for ((void)fgets(fname, MAX_STR_LEN, pin); !feof(pin);
     919         (void)fgets(fname, MAX_STR_LEN, pin)) {
    920920        if ((fname[strlen(fname) - 1] == 13
    921921             || fname[strlen(fname) - 1] == 10) && strlen(fname) > 0) {
     
    13891389        malloc_string(name_of_evalcall_form);
    13901390        malloc_string(find_skeleton_marker);
    1391         asprintf(&find_excludes, " ");
     1391        (void)asprintf(&find_excludes, " ");
    13921392        while((token = mr_strtok (sth, delims, &lastpos))) {
    1393           asprintf(&strtmp,"%s", find_excludes);
     1393          (void)asprintf(&strtmp,"%s", find_excludes);
    13941394          paranoid_free(find_excludes);
    1395           asprintf(&find_excludes,"%s -path %s -prune -o", strtmp, token);
     1395          (void)asprintf(&find_excludes,"%s -path %s -prune -o", strtmp, token);
    13961396          paranoid_free(strtmp);
    13971397          paranoid_free(token);
     
    13991399#if linux
    14001400        // 2.6 has /sys as a proc-type thing -- must be excluded
    1401         asprintf(&strtmp,
     1401        (void)asprintf(&strtmp,
    14021402             "find '%s' -fstype mvfs -prune -o -fstype devpts -prune -o -fstype tmpfs -prune -o -fstype proc -prune -o -fstype sysfs -prune -o %s -type d -print > %s 2> /dev/null",
    14031403             dir, find_excludes, g_skeleton_filelist);
    14041404#else
    14051405        // On BSD, for example, /sys is the kernel sources -- don't exclude
    1406         asprintf(&strtmp,
     1406        (void)asprintf(&strtmp,
    14071407             "find '%s' -fstype mvfs -prune -o -path /proc -prune -o %s -type d -print > %s 2> /dev/null",
    14081408                dir, find_excludes, g_skeleton_filelist);
     
    14101410        paranoid_free(find_excludes);
    14111411        log_msg(5, "find command = %s", strtmp);
    1412         system(strtmp);
     1412        (void)system(strtmp);
    14131413        paranoid_free(strtmp);
    1414         asprintf(&tmp, "wc -l %s | awk '{print $1;}'", g_skeleton_filelist);
     1414        (void)asprintf(&tmp, "wc -l %s | awk '{print $1;}'", g_skeleton_filelist);
    14151415        g_skeleton_entries =
    14161416            1 + atol(call_program_and_get_last_line_of_output(tmp));
     
    14421442#ifndef _XWIN
    14431443                if (!g_text_mode) {
    1444                     asprintf(&tmp, "Reading %-68s", dir);
     1444                    (void)asprintf(&tmp, "Reading %-68s", dir);
    14451445                    newtDrawRootText(0, g_noof_rows - 3, tmp);
    14461446                    paranoid_free(tmp);
     
    14561456//  log_msg(0, "Cataloguing %s", dir);
    14571457    if (sth[0] == ' ') {
    1458         asprintf(&skip_these, "%s", sth);
     1458        (void)asprintf(&skip_these, "%s", sth);
    14591459    } else {
    1460         asprintf(&skip_these, " %s ", sth);
    1461     }
    1462     asprintf(&new_with_spaces, " %s ", dir);
     1460        (void)asprintf(&skip_these, " %s ", sth);
     1461    }
     1462    (void)asprintf(&new_with_spaces, " %s ", dir);
    14631463    if ((dip = opendir(dir)) == NULL) {
    1464         asprintf(&tmp,"opendir %s", dir);
     1464        (void)asprintf(&tmp,"opendir %s", dir);
    14651465        log_OS_error(tmp);
    14661466        paranoid_free(tmp);
     
    14721472            i++;
    14731473            if (strcmp(dir, "/")) {
    1474                 asprintf(&new,"%s/%s",dir,dit->d_name);
     1474                (void)asprintf(&new,"%s/%s",dir,dit->d_name);
    14751475            } else {
    1476                 asprintf(&new,"%s%s",dir,dit->d_name);
     1476                (void)asprintf(&new,"%s%s",dir,dit->d_name);
    14771477            }
    14781478            paranoid_free(new_with_spaces);
    1479             asprintf(&new_with_spaces, " %s ", new);
     1479            (void)asprintf(&new_with_spaces, " %s ", new);
    14801480            if (strstr(skip_these, new_with_spaces)) {
    14811481                fprintf(fout, "%s\n", new);
     
    14961496                                counter = 0;
    14971497                                uberctr++;
    1498                                 asprintf(&tmp, " %c ",
     1498                                (void)asprintf(&tmp, " %c ",
    14991499                                        special_dot_char(uberctr));
    15001500#ifndef _XWIN
     
    15501550    bool in_quotes = FALSE;
    15511551
    1552     asprintf(&sz_res, "%s", incoming);
     1552    (void)asprintf(&sz_res, "%s", incoming);
    15531553    p = sz_res;
    15541554    while ((*p != ' ' || in_quotes) && *p != '\0') {
     
    15981598        fatal_error("Cannot malloc exclude_paths");
    15991599    }
    1600     asprintf(&sz_datefile,MONDO_CACHE"/difflevel.%d" , 0);
     1600    (void)asprintf(&sz_datefile,MONDO_CACHE"/difflevel.%d" , 0);
    16011601    if (!include_paths && !userdef_filelist) {
    16021602        fatal_error
     
    16061606    sprintf(command, "mkdir -p %s/archives", scratchdir);
    16071607    paranoid_system(command);
    1608     asprintf(&sz_filelist, "%s/tmpfs/filelist.full", tmpdir);
     1608    (void)asprintf(&sz_filelist, "%s/tmpfs/filelist.full", tmpdir);
    16091609    make_hole_for_file(sz_filelist);
    16101610
     
    16461646        log_msg(2, "include_paths = '%s'", include_paths);
    16471647        log_msg(1, "Calculating filelist");
    1648         asprintf(&tmp2, "%s", call_program_and_get_last_line_of_output("mount | grep -Ew 'ntfs|ntfs-3g|fat|vfat|dos' | awk '{print $3}'"));
     1648        (void)asprintf(&tmp2, "%s", call_program_and_get_last_line_of_output("mount | grep -Ew 'ntfs|ntfs-3g|fat|vfat|dos' | awk '{print $3}'"));
    16491649        if (strlen(tmp2) < 1) {
    1650             asprintf(&tmp1," ");
     1650            (void)asprintf(&tmp1," ");
    16511651        } else {
    16521652            log_msg(2, "Found windows FS: %s",tmp2);
    1653             asprintf(&tmp1, "find %s -name '/win386.swp' -o -name '/hiberfil.sys' -o -name '/pagefile.sys' 2> /dev/null\n",tmp2);
     1653            (void)asprintf(&tmp1, "find %s -name '/win386.swp' -o -name '/hiberfil.sys' -o -name '/pagefile.sys' 2> /dev/null\n",tmp2);
    16541654            paranoid_free(tmp2);
    1655             asprintf(&tmp2, "%s", call_program_and_get_last_line_of_output(tmp1));
     1655            (void)asprintf(&tmp2, "%s", call_program_and_get_last_line_of_output(tmp1));
    16561656            log_msg(2, "Found windows files: %s",tmp2);
    16571657        }
     
    18131813//      fscanf(fin, "%s\n", fname);
    18141814        len = MAX_STR_LEN - 1;
    1815         getline(&fname, &len, fin); // patch by Scrub
     1815        (void)getline(&fname, &len, fin);   // patch by Scrub
    18161816        if (!use_star) {
    18171817            if (fname[0] == '/') {
     
    18831883        return (1);
    18841884    }
    1885     for (fgets(tmp, MAX_STR_LEN, fin); !feof(fin);
    1886          fgets(tmp, MAX_STR_LEN, fin)) {
     1885    for ((void)fgets(tmp, MAX_STR_LEN, fin); !feof(fin);
     1886         (void)fgets(tmp, MAX_STR_LEN, fin)) {
    18871887        if (!tmp[0]) {
    18881888            continue;
Note: See TracChangeset for help on using the changeset viewer.