Changeset 2350 in MondoRescue for branches/2.2.9/mondo/src/common


Ignore:
Timestamp:
Aug 28, 2009, 2:24:19 AM (16 years ago)
Author:
Bruno Cornec
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/src/common
Files:
6 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);
Note: See TracChangeset for help on using the changeset viewer.