Changeset 2350


Ignore:
Timestamp:
Aug 28, 2009, 2:24:19 AM (10 years ago)
Author:
bruno
Message:

Change inerface of evaluate_mountlist and spread_flaws_across_three_lines in order to solve bugs linked to strings management in these functions. May fix a restoration crash seen by some customers

Location:
branches/2.2.9/mondo
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.9/mondo/src/common/libmondo-mountlist-EXT.h

    r2202 r2350  
    11/* libmondo-mountlist-EXT.h */
    22
    3 extern int evaluate_mountlist(struct mountlist_itself *mountlist,
    4                               char *flaws_str_A, char *flaws_str_B,
    5                               char *flaws_str_C);
     3extern char *evaluate_mountlist(struct mountlist_itself *mountlist, int *res);
    64extern int find_device_in_mountlist(struct mountlist_itself *mountlist,
    75                                    char *device);
  • branches/2.2.9/mondo/src/common/libmondo-mountlist.c

    r2304 r2350  
    500500 * @see evaluate_drive_within_mountlist
    501501 */
    502 int
    503 evaluate_mountlist(struct mountlist_itself *mountlist, char *flaws_str_A,
    504                    char *flaws_str_B, char *flaws_str_C)
    505 {
     502char *evaluate_mountlist(struct mountlist_itself *mountlist, int *res) {
    506503
    507504    /*@ buffer *********************************************************** */
     
    512509    /*@ int ************************************************************** */
    513510    int i = 0;
    514     int res = 0;
    515511
    516512    /*@ initialize ******************************************************* */
    517513
     514    *res = 0;
    518515    drivelist = malloc(sizeof(struct list_of_disks));
    519516    assert(mountlist != NULL);
    520     assert(flaws_str_A != NULL);
    521     assert(flaws_str_B != NULL);
    522     assert(flaws_str_C != NULL);
    523517
    524518    mr_asprintf(&flaws_str, "%s", "");
     
    539533            tmp = evaluate_drive_within_mountlist(mountlist, drivelist->el[i].device);
    540534            if (tmp == NULL) {
    541                 res++;
     535                (*res)++;
    542536            }
    543537        }
     
    550544        }
    551545    }
    552     res += look_for_duplicate_mountpoints(mountlist, flaws_str);
    553     res = spread_flaws_across_three_lines(flaws_str, flaws_str_A, flaws_str_B, flaws_str_C,res);
    554     paranoid_free(flaws_str);
    555     return(res);
     546    *res += look_for_duplicate_mountpoints(mountlist, flaws_str);
     547    return(flaws_str);
    556548}
    557549
  • branches/2.2.9/mondo/src/common/libmondo-mountlist.h

    r2202 r2350  
    44
    55
    6 int evaluate_mountlist(struct mountlist_itself *mountlist,
    7                        char *flaws_str_A, char *flaws_str_B,
    8                        char *flaws_str_C);
     6char *evaluate_mountlist(struct mountlist_itself *mountlist, int *res);
    97int find_device_in_mountlist(struct mountlist_itself *mountlist,
    108                             char *device);
  • branches/2.2.9/mondo/src/common/libmondo-string-EXT.h

    r1647 r2350  
    2121                         char *s);
    2222extern int special_dot_char(int i);
    23 extern bool spread_flaws_across_three_lines(char *flaws_str,
     23extern void spread_flaws_across_three_lines(char *flaws_str,
    2424                                            char *flaws_str_A,
    2525                                            char *flaws_str_B,
    26                                             char *flaws_str_C, int res);
     26                                            char *flaws_str_C);
    2727extern int strcmp_inc_numbers(char *stringA, char *stringB);
    2828extern char *strip_afio_output_line(char *input);
  • branches/2.2.9/mondo/src/common/libmondo-string.c

    r2242 r2350  
    608608 * @param flaws_str_B Where to put the second 74-or-less characters.
    609609 * @param flaws_str_C Where to put the rest.
    610  * @param res The result of the original evaluate_mountlist() operation.
    611  * @return TRUE if res == 0, FALSE otherwise.
    612  */
    613 bool
     610 */
     611void
    614612spread_flaws_across_three_lines(char *flaws_str, char *flaws_str_A,
    615                                 char *flaws_str_B, char *flaws_str_C,
    616                                 int res)
     613                                char *flaws_str_B, char *flaws_str_C)
    617614{
    618615
     
    621618
    622619    /*@ initialize ****************************************************** */
    623     assert(flaws_str_A != NULL);
    624     assert(flaws_str_B != NULL);
    625     assert(flaws_str_C != NULL);
    626620    assert(flaws_str != NULL);
    627621
    628     if (!res && !strlen(flaws_str)) {
    629         return (TRUE);
    630     }
    631622    if (strlen(flaws_str) > 0) {
    632         paranoid_free(flaws_str_A);
    633623        mr_asprintf(&flaws_str_A, "%s", flaws_str + 1);
    634624    }
    635625    if (strlen(flaws_str_A) >= 74) {
    636626        for (i = 74; flaws_str_A[i] != ' '; i--);
    637         paranoid_free(flaws_str_B);
    638627        mr_asprintf(&flaws_str_B, "%s", flaws_str_A + i + 1);
    639628        flaws_str_A[i] = '\0';
     
    641630    if (strlen(flaws_str_B) >= 74) {
    642631        for (i = 74; flaws_str_B[i] != ' '; i--);
    643         paranoid_free(flaws_str_C);
    644632        mr_asprintf(&flaws_str_C, "%s", flaws_str_B + i + 1);
    645633        flaws_str_B[i] = '\0';
    646     }
    647     if (res) {
    648         return (FALSE);
    649     } else {
    650         return (TRUE);
    651634    }
    652635}
  • branches/2.2.9/mondo/src/common/libmondo-string.h

    r1647 r2350  
    1717char *slice_fname(long bigfileno, long sliceno, char *path, char *s);
    1818int special_dot_char(int i);
    19 bool spread_flaws_across_three_lines(char *flaws_str, char *flaws_str_A,
    20                                      char *flaws_str_B, char *flaws_str_C,
    21                                      int res);
     19void spread_flaws_across_three_lines(char *flaws_str, char *flaws_str_A,
     20                                     char *flaws_str_B, char *flaws_str_C);
    2221int strcmp_inc_numbers(char *stringA, char *stringB);
    2322char *strip_afio_output_line(char *input);
  • branches/2.2.9/mondo/src/mondorestore/mondo-rstr-newt.c

    r2230 r2350  
    19331933    /** int **************************************************************/
    19341934    int i = 0;
     1935    int res = 0;
    19351936    int currline = 0;
    19361937    int finished = FALSE;
     
    19381939    /** buffers **********************************************************/
    19391940    char tmp[MAX_STR_LEN];
     1941    char *flaws_str = NULL;
    19401942    char *flaws_str_A = NULL;
    19411943    char *flaws_str_B = NULL;
     
    19451947    assert(raidlist != NULL);
    19461948
    1947     mr_asprintf(&flaws_str_A, "%s", "         ");
    1948     mr_asprintf(&flaws_str_B, "%s", "         ");
    1949     mr_asprintf(&flaws_str_C, "%s", "         ");
    19501949    if (mountlist->entries > ARBITRARY_MAXIMUM) {
    19511950        log_to_screen("Arbitrary limits suck, man!");
     
    19641963            "Size (MB)");
    19651964    headerMsg = newtLabel(2, 1, tmp);
    1966     flawsLabelA = newtLabel(2, 13, flaws_str_A);
    1967     flawsLabelB = newtLabel(2, 14, flaws_str_B);
    1968     flawsLabelC = newtLabel(2, 15, flaws_str_C);
     1965    flawsLabelA = newtLabel(2, 13, "         ");
     1966    flawsLabelB = newtLabel(2, 14, "         ");
     1967    flawsLabelC = newtLabel(2, 15, "         ");
    19691968    partitionsListbox =
    19701969        newtListbox(2, 2, 10, NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT);
     
    19761975                          bEdit, bDelete, bReload, bCancel, bOK, NULL);
    19771976    while (!finished) {
    1978         evaluate_mountlist(mountlist, flaws_str_A, flaws_str_B,
    1979                            flaws_str_C);
     1977        flaws_str = evaluate_mountlist(mountlist, &res);
     1978        spread_flaws_across_three_lines(flaws_str, flaws_str_A, flaws_str_B, flaws_str_C);
     1979
     1980        mr_free(flaws_str);
     1981
    19801982        newtLabelSetText(flawsLabelA, flaws_str_A);
    19811983        newtLabelSetText(flawsLabelB, flaws_str_B);
    19821984        newtLabelSetText(flawsLabelC, flaws_str_C);
    19831985        b_res = newtRunForm(myForm);
     1986        mr_free(flaws_str_A);
     1987        mr_free(flaws_str_B);
     1988        mr_free(flaws_str_C);
     1989
    19841990        if (b_res == bOK) {
    1985             if (!evaluate_mountlist
    1986                 (mountlist, flaws_str_A, flaws_str_B, flaws_str_C)) {
     1991            flaws_str = evaluate_mountlist(mountlist, &res);
     1992            mr_free(flaws_str);
     1993            if (!res) {
    19871994                finished =
    19881995                    ask_me_yes_or_no
     
    20382045        }
    20392046    }
    2040     paranoid_free(flaws_str_A);
    2041     paranoid_free(flaws_str_B);
    2042     paranoid_free(flaws_str_C);
    20432047    newtFormDestroy(myForm);
    20442048    newtPopWindow();
  • branches/2.2.9/mondo/src/mondorestore/mondo-rstr-newt.h

    r2202 r2350  
    137137                   struct raidlist_itself *);
    138138void edit_raidrec_additional_vars(struct raid_device_record *);
    139 int evaluate_mountlist(struct mountlist_itself *, char *, char *, char *);
     139char *evaluate_mountlist(struct mountlist_itself *, int *);
    140140int find_device_in_mountlist(struct mountlist_itself *, char *);
    141141int find_next_free_index_in_disklist(struct list_of_disks *);
     
    180180void setup_newt_stuff(void);
    181181long size_of_specific_device(struct mountlist_itself *, char *);
    182 bool spread_flaws_across_three_lines(char *, char *, char *, char *, int);
     182void spread_flaws_across_three_lines(char *, char *, char *, char *);
    183183char *turn_raid_level_number_to_string(int);
    184184void update_evalcall_form(int);
  • branches/2.2.9/mondo/src/mondorestore/mondorestore.c

    r2290 r2350  
    777777  /** malloc **/
    778778    char tmp[MAX_STR_LEN];
    779     char *tmpA;
    780     char *tmpB;
    781     char *tmpC;
     779    char *flaws_str = NULL;
    782780
    783781    assert(bkpinfo != NULL);
    784782    assert(mountlist != NULL);
    785783    assert(raidlist != NULL);
    786 
    787     mr_asprintf(&tmpA, "%s", "         ");
    788     mr_asprintf(&tmpB, "%s", "         ");
    789     mr_asprintf(&tmpC, "%s", "         ");
    790784
    791785    log_msg(2, "nuke_mode --- starting");
     
    807801        resize_mountlist_proportionately_to_suit_new_drives(mountlist);
    808802    }
    809     if (!evaluate_mountlist(mountlist, tmpA, tmpB, tmpC)) {
     803    flaws_str = evaluate_mountlist(mountlist, &res);
     804    if (!res) {
    810805        sprintf(tmp,
    811                 "Mountlist analyzed. Result: \"%s %s %s\" Switch to Interactive Mode?",
    812                 tmpA, tmpB, tmpC);
     806                "Mountlist analyzed. Result: \"%s\" Switch to Interactive Mode?",
     807                flaws_str);
     808        mr_free(flaws_str);
    813809        if (ask_me_yes_or_no(tmp)) {
    814810            retval = interactive_mode(mountlist, raidlist);
     
    818814        }
    819815    }
     816    mr_free(flaws_str);
     817
    820818    save_mountlist_to_disk(mountlist, g_mountlist_fname);
    821819    mvaddstr_and_log_it(1, 30, "Restoring Automatically");
  • branches/2.2.9/mondo/src/mondorestore/mr-externs.h

    r2109 r2350  
    109109extern bool g_restoring_live_from_nfs;
    110110extern int fput_string_one_char_at_a_time(FILE *, char *);
    111 
    112 
    113 
    114 
    115 
    116 extern int
    117 evaluate_mountlist(struct mountlist_itself *mountlist, char *flaws_str_A,
    118                    char *flaws_str_B, char *flaws_str_C);
    119 
     111extern char *evaluate_mountlist(struct mountlist_itself *mountlist, int *res);
    120112
    121113
  • branches/2.2.9/mondo/test/test-mountlist.c

    r2235 r2350  
    4949
    5050struct mountlist_itself *mountlist = NULL;
    51 struct raidlist_itself *raidlist;
    52 char *tmpA = NULL;
    53 char *tmpB = NULL;
    54 char *tmpC = NULL;
    55 bool ret = FALSE;
     51struct raidlist_itself *raidlist = NULL;
     52int ret = 0;
     53char *flaws_str = NULL;
    5654
    5755mr_asprintf(&MONDO_LOGFILE,"/tmp/mrtest-mountlist.log");
     
    8280log_it("after edit_mountlist");
    8381
    84 mr_asprintf(&tmpA, "%s", "         ");
    85 mr_asprintf(&tmpB, "%s", "         ");
    86 mr_asprintf(&tmpC, "%s", "         ");
    87 ret = evaluate_mountlist(mountlist, tmpA, tmpB, tmpC);
     82flaws_str = evaluate_mountlist(mountlist, &ret);
    8883log_it("after evaluate_mountlist");
     84mr_free(flaws_str);
    8985
    9086mr_free(MONDO_LOGFILE);
Note: See TracChangeset for help on using the changeset viewer.