Changeset 3076


Ignore:
Timestamp:
Nov 24, 2012, 8:23:58 PM (7 years ago)
Author:
bruno
Message:
  • Avoids again some additional warnings at compilation level
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.0/mondo/src/mondorestore/mondo-rstr-tools.c

    r2982 r3076  
    119119char *incoming_ptr;
    120120char *question_ptr;
     121char *q;
    121122
    122123char incoming[MAX_STR_LEN] = "\0";
     
    128129incoming_ptr = malloc(sizeof(incoming));
    129130if (incoming_ptr == NULL) {
    130 fprintf(stderr, "Out of Memory\n");
    131 exit(EXIT_FAILURE);
     131    fprintf(stderr, "Out of Memory\n");
     132    exit(EXIT_FAILURE);
    132133}
    133134
    134135question_ptr = malloc(sizeof(question));
    135136if (question_ptr == NULL) {
    136 fprintf(stderr, "Out of Memory\n");
    137 exit(EXIT_FAILURE);
     137    fprintf(stderr, "Out of Memory\n");
     138    exit(EXIT_FAILURE);
    138139}
    139140
     
    144145
    145146if (!(fin = fopen(infname, "r"))) {
    146 fatal_error("Cannot openin infname");
     147    fatal_error("Cannot openin infname");
    147148}
    148149if (!(fout = fopen(outfname, "w"))) {
    149 fatal_error("Cannot openin outfname");
    150 }
    151 for (fgets(incoming_ptr, MAX_STR_LEN, fin);
    152  !feof(fin); fgets(incoming_ptr, MAX_STR_LEN, fin)) {
    153 strip_spaces(incoming_ptr);
    154 
    155 if (incoming[0] == '\0') {
    156     continue;
    157 }
    158 
    159 sprintf(question_ptr,
    160         "Should I restore the image of %s ?", incoming_ptr);
    161 
    162 if (ask_me_yes_or_no(question_ptr)) {
    163     fprintf(fout, "%s\n", incoming_ptr);
    164 }
     150    fatal_error("Cannot openin outfname");
     151}
     152for (q = fgets(incoming_ptr, MAX_STR_LEN, fin); !feof(fin) && (q != NULL); q = fgets(incoming_ptr, MAX_STR_LEN, fin)) {
     153    strip_spaces(incoming_ptr);
     154
     155    if (incoming[0] == '\0') {
     156        continue;
     157    }
     158
     159    sprintf(question_ptr, "Should I restore the image of %s ?", incoming_ptr);
     160
     161    if (ask_me_yes_or_no(question_ptr)) {
     162        fprintf(fout, "%s\n", incoming_ptr);
     163    }
    165164}
    166165
     
    10051004char *command;
    10061005char *tmp;
     1006char *q;
    10071007int res = 0;
    10081008pid_t pid;
     
    10281028} else {
    10291029    getcwd(tmp, MAX_STR_LEN);
    1030     chdir(bkpinfo->tmpdir);
     1030    if (chdir(bkpinfo->tmpdir)) {
     1031        // FIXME
     1032    }
    10311033    log_msg(1, "chdir(%s)", bkpinfo->tmpdir);
    10321034    log_to_screen("Extracting filelist and biggielist from media...");
     
    11281130    }
    11291131
    1130     chdir(tmp);
     1132    if (chdir(tmp)) {
     1133        // FIXME
     1134    }
    11311135
    11321136    if (!does_file_exist(g_biggielist_txt)) {
     
    11711175    unlink(g_filelist_full);
    11721176    if (g_text_mode) {
    1173         printf("Restore which directory? --> ");
    1174         fgets(tmp, sizeof(tmp), stdin);
     1177        q = NULL;
     1178        while (q == NULL) {
     1179            printf("Restore which directory? --> ");
     1180            q = fgets(tmp, sizeof(tmp), stdin);
     1181        }
    11751182        toggle_path_selection(filelist, tmp, TRUE);
    11761183        if (strlen(tmp) == 0) {
     
    12551262            newtSuspend();
    12561263        }
    1257         (void)system("chroot " MNT_RESTORING);
     1264        paranoid_system("chroot " MNT_RESTORING);
    12581265        if (!g_text_mode) {
    12591266            newtResume();
     
    13121319    log_msg(2, tmp);
    13131320    paranoid_free(tmp);
    1314     system("sync");
     1321    paranoid_system("sync");
    13151322
    13161323    offer_to_make_initrd();
     
    14891496                        ("GRUB installation failed. Please fix the conf files so that a manual install using 'grub-install' or similar command works. You are now chroot()'ed to your restored system. Please type 'exit' when you are done.");
    14901497                    newtSuspend();
    1491                     system("chroot " MNT_RESTORING);
     1498                    paranoid_system("chroot " MNT_RESTORING);
    14921499                    newtResume();
    14931500                    popup_and_OK("Thank you.");
     
    15121519                ("Because of bugs in GRUB's own installer, GRUB was not installed properly. Please install the boot loader manually now, using this chroot()'ed shell prompt. Type 'exit' when you have finished.");
    15131520            newtSuspend();
    1514             system("chroot " MNT_RESTORING);
     1521            paranoid_system("chroot " MNT_RESTORING);
    15151522            newtResume();
    15161523            popup_and_OK("Thank you.");
     
    18721879  /** malloc **/
    18731880    char *incoming;
     1881    char *q;
    18741882
    18751883    assert_string_is_neither_NULL_nor_zerolength(output_file);
     
    18841892        fatal_error("cannot open output_file");
    18851893    }
    1886     for (fgets(incoming, MAX_STR_LEN - 1, fin); !feof(fin);
    1887          fgets(incoming, MAX_STR_LEN - 1, fin)) {
     1894    for (q = fgets(incoming, MAX_STR_LEN - 1, fin); !feof(fin) && (q != NULL);
     1895         q = fgets(incoming, MAX_STR_LEN - 1, fin)) {
    18881896        if (strncmp(incoming, "etc/adjtime", 11)
    18891897            && strncmp(incoming, "etc/mtab", 8)
     
    19641972                       "in preparation for the post-restoration reboot.",
    19651973                       "", mountlist->entries);
    1966     chdir("/");
     1974    if (chdir("/")) {
     1975        // FIXME
     1976    }
    19671977    for (i = 0;
    19681978         i < 10
     
    21532163    sprintf(mountpt, "%s/mount.bootdisk", bkpinfo->tmpdir);
    21542164    device[0] = '\0';
    2155     chdir(bkpinfo->tmpdir);
     2165    if (chdir(bkpinfo->tmpdir)) {
     2166        // FIXME
     2167    }
    21562168    strcpy(cfg_file, MONDO_CFG_FILE_STUB);
    21572169    unlink(cfg_file);           // cfg_file[] is missing the '/' at the start, FYI, by intent
     
    21862198        if (try_plan_B) {
    21872199            log_msg(2, "gcffa --- OK, switching to Plan B");
    2188             chdir(bkpinfo->tmpdir);
     2200            if (chdir(bkpinfo->tmpdir)) {
     2201                // FIXME
     2202            }
    21892203            run_program_and_log_output("mkdir -p tmp", FALSE);
    21902204
Note: See TracChangeset for help on using the changeset viewer.