Changeset 3892 in MondoRescue for branches/3.3/mondo/src/common


Ignore:
Timestamp:
Mar 12, 2024, 3:10:24 AM (3 months ago)
Author:
Bruno Cornec
Message:

More compiler fixes

  • Fix unused vars
  • Fix FreeBSD #if alone
  • Use MDSTAT_FILE everywhere
  • Fix missing break
  • Fix some strncpy. mr_strncpy used when safe
  • Fix wrong g_isoform_header_str proto !
  • find-cd & find-dvd => find-optical
Location:
branches/3.3/mondo/src/common
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • branches/3.3/mondo/src/common/libmondo-archive.c

    r3891 r3892  
    14461446 * @param ntfsprog_fifo The FIFO to ntfsclone if this is an imagedev, NULL otherwise.
    14471447 * @param biggie_file_number The sequence number of this biggie file (starting from 0).
    1448  * @param noof_biggie_files The number of biggie files there are total.
    14491448 * @return The number of errors encountered (0 for success)
    14501449 * @see make_slices_and_images
    14511450 * @ingroup LLarchiveGroup
    14521451 */
    1453 int slice_up_file_etc(char *biggie_filename, char *ntfsprog_fifo, long biggie_file_number, long noof_biggie_files, bool use_ntfsprog) {
     1452int slice_up_file_etc(char *biggie_filename, char *ntfsprog_fifo, long biggie_file_number, bool use_ntfsprog) {
    14541453
    14551454    /*@ buffers ************************************************** */
     
    18121811                write_header_block_to_stream(biggie_fsize, bigfile_fname, use_ntfsprog ?  BLK_START_A_PIHBIGGIE : BLK_START_A_NORMBIGGIE);
    18131812            }
    1814             res = slice_up_file_etc(bigfile_fname, ntfsprog_fifo, biggie_file_number, noof_biggie_files, use_ntfsprog);
     1813            res = slice_up_file_etc(bigfile_fname, ntfsprog_fifo, biggie_file_number, use_ntfsprog);
    18151814
    18161815            /* Free it here as ntfsprog_fifo is not used anymore */
     
    24172416    if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    24182417        write_header_block_to_stream((off_t)0, "start-of-afioballs", BLK_START_AFIOBALLS);
     2418#ifdef __FreeBSD__
    24192419#if __FreeBSD__ == 5
    24202420        log_msg(1, "Using single-threaded make_afioballs_and_images() to suit b0rken FreeBSD 5.0");
    24212421        res = make_afioballs_and_images_OLD();
     2422#endif
    24222423#else
    24232424        res = make_afioballs_and_images_OLD();
     
    26432644    mr_asprintf(broken_bios_sz, "yes"); /* assume so */
    26442645
    2645     if (pkpinfo->auto_recovery) {
     2646    if (bkpinfo->auto_recovery) {
    26462647        mr_asprintf(cd_recovery_sz, "yes");
    26472648    } else {
  • branches/3.3/mondo/src/common/libmondo-cli.c

    r3890 r3892  
    998998void termination_in_progress(int sig)
    999999{
    1000     log_msg(1, "Termination in progress");
     1000    log_msg(1, "Termination in progress by signal %d",sig);
    10011001    usleep(1000);
    10021002    pthread_exit(0);
  • branches/3.3/mondo/src/common/libmondo-devices.c

    r3889 r3892  
    443443                mr_free(mount_list);
    444444
    445                 mr_asprintf(command, "%s", "cat /proc/mdstat|grep -iv Personal|awk '{if($0~\"^.*[ ]+:\"){printf(\"/dev/%s \", $1)}}END{print \"\"}'");
     445                mr_asprintf(command, "%s", "cat " MDSTAT_FILE " |grep -iv Personal|awk '{if($0~\"^.*[ ]+:\"){printf(\"/dev/%s \", $1)}}END{print \"\"}'");
    446446                log_msg (5, "Running: %s", command);
    447447                mount_list = call_program_and_get_last_line_of_output(command);
     
    499499
    500500        /* Get the Software raid device list */
    501         mr_asprintf(command, "%s", "cat /proc/mdstat|grep -iv Personal|awk '{if($0~\"^.*[ ]+:\"){printf(\"/dev/%s \", $1)}}END{print \"\"}'");
     501        mr_asprintf(command, "%s", "cat " MDSTAT_FILE " | grep -iv Personal|awk '{if($0~\"^.*[ ]+:\"){printf(\"/dev/%s \", $1)}}END{print \"\"}'");
    502502        log_msg (5, "  Running: %s", command);
    503503        mount_list = call_program_and_get_last_line_of_output(command);
     
    788788bool does_nonMS_partition_exist(void)
    789789{
    790 #if __FreeBSD__
     790#ifdef __FreeBSD__
    791791    return
    792792        !system("for drive in /dev/ad? /dev/da?; do fdisk $drive | grep -q FreeBSD && exit 0; done; false");
     
    21362136
    21372137    case udev:
    2138         if (!ask_me_yes_or_no
    2139             ("This option is for advanced users only. Are you sure?")) {
     2138        if (!ask_me_yes_or_no("This option is for advanced users only. Are you sure?")) {
    21402139            log_to_screen("User has chosen not to backup the machine");
    21412140            finish(1);
    21422141        }
     2142        break;
     2143
    21432144    case tape:
    21442145
     
    24832484// NTFS
    24842485        tmp = call_program_and_get_last_line_of_output("mr-parted2fdisk -l 2>/dev/null | grep -i ntfs | awk '{ print $1};' | tr -s '\\n' ' ' | awk '{ print $0};'");
    2485         strncpy(tmp1, tmp,(MAX_STR_LEN / 4)-1);
     2486        if (strlen(tmp) > 2) {
     2487            tmp1 = mr_popup_and_get_string("NTFS partitions", "Please enter/confirm the NTFS partitions you wish to backup as well.", tmp);
     2488            if (tmp1 == NULL) {
     2489                log_to_screen("User has chosen not to backup the machine");
     2490                mr_free(tmp);
     2491                mr_free(tmp1);
     2492                finish(1);
     2493            }
     2494            mr_free(bkpinfo->image_devs);
     2495            bkpinfo->image_devs = tmp1;
     2496        }
    24862497        mr_free(tmp);
    2487         if (strlen(tmp1) > 2) {
    2488             if (!popup_and_get_string("NTFS partitions", "Please enter/confirm the NTFS partitions you wish to backup as well.", tmp1,(MAX_STR_LEN / 4)-1)) {
    2489                 log_to_screen("User has chosen not to backup the machine");
    2490                 finish(1);
    2491             }
    2492             mr_asprintf(bkpinfo->image_devs, "%s", tmp1);
    2493         }
    24942498
    24952499        if (bkpinfo->exclude_paths != NULL ) {
     
    25722576        mr_free(compression_type);
    25732577
     2578#ifdef __FreeBSD__
    25742579#if __FreeBSD__ == 5
    25752580        mr_asprintf(bkpinfo->kernel_path, "%s", "/boot/kernel/kernel");
    25762581#elif __FreeBSD__ == 4
    25772582        mr_asprintf(bkpinfo->kernel_path, "%s", "/kernel");
     2583#endif
    25782584#elif linux
    25792585        if (figure_out_kernel_path_interactively_if_necessary(bkpinfo->kernel_path)) {
  • branches/3.3/mondo/src/common/libmondo-filelist.c

    r3879 r3892  
    14821482/**
    14831483 * Create the filelist for the backup. It will be stored in [scratchdir]/archives/filelist.full.
    1484  * @param logfile Unused.
    14851484 * @param tmpdir The tmpdir of the backup.
    14861485 * @param scratchdir The scratchdir of the backup.
     
    14901489 * @param userdef_filelist The user-defined filelist, or NULL if you're using @p include_paths.
    14911490 * @return 0, always.
    1492  * @bug @p logfile is unused.
    14931491 * @bug Return value is meaningless.
    14941492 */
    1495 int mondo_makefilelist(char *logfile, char *tmpdir, char *scratchdir,
     1493int mondo_makefilelist(char *tmpdir, char *scratchdir,
    14961494                       char *include_paths, char *excp, int differential,
    14971495                       char *userdef_filelist)
     
    16571655
    16581656    if (bkpinfo->make_filelist) {
    1659         res = mondo_makefilelist(MONDO_LOGFILE, bkpinfo->tmpdir, bkpinfo->scratchdir, bkpinfo->include_paths, bkpinfo->exclude_paths, bkpinfo->differential, NULL);
     1657        res = mondo_makefilelist(bkpinfo->tmpdir, bkpinfo->scratchdir, bkpinfo->include_paths, bkpinfo->exclude_paths, bkpinfo->differential, NULL);
    16601658    } else {
    1661         res = mondo_makefilelist(MONDO_LOGFILE, bkpinfo->tmpdir, bkpinfo->scratchdir, NULL, bkpinfo->exclude_paths, bkpinfo->differential, bkpinfo->include_paths);
     1659        res = mondo_makefilelist(bkpinfo->tmpdir, bkpinfo->scratchdir, NULL, bkpinfo->exclude_paths, bkpinfo->differential, bkpinfo->include_paths);
    16621660    }
    16631661
  • branches/3.3/mondo/src/common/libmondo-raid.c

    r3879 r3892  
    5656        mr_strcat(command, "raid%d", raidno);
    5757    }
    58     mr_strcat(command, "\" /proc/mdstat > /dev/null 2> /dev/null");
     58    mr_strcat(command, "\" " MDSTAT_FILE " > /dev/null 2> /dev/null");
    5959    log_it("Is raid %d registered? Command = '%s'", raidno, command);
    6060    res = system(command);
  • branches/3.3/mondo/src/common/libmondo-stream.c

    r3882 r3892  
    317317{
    318318    int res = 0;
    319     char *command = NULL;
    320319
    321320    if (bkpinfo->media_device == NULL) {
  • branches/3.3/mondo/src/common/libmondo-string.c

    r3882 r3892  
    387387    switch (i) {
    388388    case 0:
    389         mr_asprintf(output, "zero");
     389        mr_asprintf(output, "%s", "zero");
    390390        break;
    391391    case 1:
    392         mr_asprintf(output, "one");
     392        mr_asprintf(output, "%s", "one");
    393393        break;
    394394    case 2:
    395         mr_asprintf(output, "two");
     395        mr_asprintf(output, "%s", "two");
    396396        break;
    397397    case 3:
    398         mr_asprintf(output, "three");
     398        mr_asprintf(output, "%s", "three");
    399399        break;
    400400    case 4:
    401         mr_asprintf(output, "four");
     401        mr_asprintf(output, "%s", "four");
    402402        break;
    403403    case 5:
    404         mr_asprintf(output, "five");
     404        mr_asprintf(output, "%s", "five");
    405405        break;
    406406    case 6:
    407         mr_asprintf(output, "six");
     407        mr_asprintf(output, "%s", "six");
    408408        break;
    409409    case 7:
    410         mr_asprintf(output, "seven");
     410        mr_asprintf(output, "%s", "seven");
    411411        break;
    412412    case 8:
    413         mr_asprintf(output, "eight");
     413        mr_asprintf(output, "%s", "eight");
    414414        break;
    415415    case 9:
    416         mr_asprintf(output, "nine");
     416        mr_asprintf(output, "%s", "nine");
     417        break;
    417418    case 10:
    418         mr_asprintf(output, "ten");
     419        mr_asprintf(output, "%s", "ten");
     420        break;
    419421    default:
    420422        mr_asprintf(output, "%d", i);
     423        break;
    421424    }
    422425    return (output);
  • branches/3.3/mondo/src/common/libmondo-tools.c

    r3890 r3892  
    735735
    736736    if (!run_program_and_log_output("mr-parted2fdisk -l 2>/dev/null | grep -i raid", 1) && !does_file_exist("/etc/raidtab")) {
    737         log_to_screen("You have RAID partitions but no /etc/raidtab - creating one from /proc/mdstat");
     737        log_to_screen("You have RAID partitions but no /etc/raidtab - creating one from " MDSTAT_FILE);
    738738        create_raidtab_from_mdstat(MDSTAT_FILE,"/etc/raidtab");
    739739    }
  • branches/3.3/mondo/src/common/libmondo-verify.c

    r3878 r3892  
    345345 * @param bkpinfo The backup information structure. @c bkpinfo->tmpdir is the only field used.
    346346 * @param biggie_fname The filename of the biggiefile to verify.
    347  * @param size The size in bytes of said biggiefile.
     347 * @param size The size in bytes of said biggiefile. TODO: Removed as not used. Is it linked to slice_siz ?
    348348 * @return 0 for success (even if the file doesn't match); nonzero for a tape error.
    349349 */
    350350int
    351 verify_a_biggiefile_from_stream(char *biggie_fname, long long size)
     351verify_a_biggiefile_from_stream(char *biggie_fname)
    352352{
    353353
     
    609609        if (bkpinfo->restore_path != NULL) {
    610610            mr_asprintf(logical_fname, "%s/%s", bkpinfo->restore_path, orig_fname);
    611             res = verify_a_biggiefile_from_stream(logical_fname, size);
     611            res = verify_a_biggiefile_from_stream(logical_fname);
    612612            mr_free(logical_fname);
    613613            retval += res;
  • branches/3.3/mondo/src/common/newt-specific.c

    r3882 r3892  
    7979    long g_isoform_starttime;   ///< The time (in seconds since the epoch) that the evalcall form was opened.
    8080    int g_isoform_old_progress = -1;    ///< The most recent progress update of the evalcall form (percent).
    81     char g_isoform_header_str = NULL;   ///< The string for the evalcall form title.
     81    char *g_isoform_header_str = NULL;  ///< The string for the evalcall form title.
    8282    int g_mysterious_dot_counter;   ///< The counter for the twirling baton (/ | \\ - ...) on percentage less than 3
    8383    int g_noof_log_lines = 6;   ///< The number of lines to show in the log at the bottom of the screen.
     
    602602
    603603        assert(ttl != NULL);
    604         //strcpy(g_isoform_header_str, ttl);
    605604        if (g_text_mode) {
    606605            log_msg(0, ttl);
     
    614613        g_isoform_starttime = get_time();
    615614        if (g_text_mode) {
    616             log_msg(0, g_isoform_header_str);
     615            log_msg(0, "g_isoform_header_str = %s", g_isoform_header_str);
    617616        } else {
    618617            g_isoform_header = newtLabel(1, 1, g_isoform_header_str);
     
    10121011        }
    10131012
    1014         /* not sure it's useful to shrink here
    1015         prompt = malloc(MAX_NEWT_COMMENT_LEN);
    1016         strncpy(prompt, p, MAX_NEWT_COMMENT_LEN - 1);
    1017         prompt[MAX_NEWT_COMMENT_LEN - 1] = '\0';
    1018         text = newtTextboxReflowed(1, 1, prompt, 40, 5, 5, 0);
    1019         */
    10201013        text = newtTextboxReflowed(1, 1, p, 40, 5, 5, 0);
    10211014        b_1 = newtButton(20 - ((button2[0] != '\0') ? strlen(button1) + 2 : strlen(button1) / 2), newtTextboxGetNumLines(text) + 3, button1);
     
    15281521 * @param flentry The filelist entry to stringify.
    15291522 * @return The string form of @p flentry.
    1530  * @note The returned value points to static storage that will be overwritten with each call.
     1523 * @note The returned value points to a dynamically allocated string that the caller needs to free.
    15311524 */
    15321525char *filelist_entry_to_string(struct s_filelist_entry *flentry) {
    1533         static char comment[100];
    1534         char *tmp = NULL;
     1526        char *comment = NULL;
    15351527
    15361528        log_msg(8, "entering");
    15371529        assert(flentry != NULL);
    15381530        if (flentry->severity == 0) {
    1539             mr_asprintf(tmp, "0   ");
     1531            mr_asprintf(comment, "0   ");
    15401532        } else if (flentry->severity == 1) {
    1541             mr_asprintf(tmp, "low ");
     1533            mr_asprintf(comment, "low ");
    15421534        } else if (flentry->severity == 2) {
    1543             mr_asprintf(tmp, "med ");
    1544         } else {
    1545             mr_asprintf(tmp, "high");
    1546         }
    1547         mr_strcat(tmp, "  ");
    1548         mr_strcat(tmp, flentry->filename);
    1549         strncpy(comment, tmp, 99);
    1550         mr_free(tmp);
    1551 
     1535            mr_asprintf(comment, "med ");
     1536        } else {
     1537            mr_asprintf(comment, "high");
     1538        }
     1539        mr_strcat(comment, "  ");
     1540        mr_strcat(comment, flentry->filename);
    15521541        log_it("leaving");
    15531542        return (comment);
     
    16151604        for (i = 0; i < filelist->entries; i++) {
    16161605            keylist[i] = (void *) i;
     1606            tmp = filelist_entry_to_string(&(filelist->el[i]));
    16171607            newtListboxAppendEntry(fileListbox,
    1618                                    filelist_entry_to_string(&
    1619                                                             (filelist->
    1620                                                              el[i])),
     1608                                    tmp,
    16211609                                   keylist[i]);
     1610            mr_free(tmp);
    16221611        }
    16231612        mr_asprintf(differ_sz, "  %ld files differ. Hit 'Select' to pick a file. Hit 'Close' to quit the list.", i);
Note: See TracChangeset for help on using the changeset viewer.