Changeset 2385


Ignore:
Timestamp:
Sep 10, 2009, 1:10:21 PM (10 years ago)
Author:
bruno
Message:
  • Remove separate function look_for_duplicate_mountpoints used only once and whose interface created problems with caller

(Backport from 2.2.9)

Location:
branches/2.2.10/mondo/src
Files:
4 edited

Legend:

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

    r2352 r2385  
    44extern int find_device_in_mountlist(struct mountlist_itself *mountlist,
    55                                    char *device);
    6 extern int look_for_duplicate_mountpoints(struct mountlist_itself
    7                                           *mountlist, char *flaws_str);
    86extern int make_list_of_drives_in_mountlist(struct mountlist_itself *,
    97                                            struct list_of_disks *);
  • branches/2.2.10/mondo/src/common/libmondo-mountlist.c

    r2382 r2385  
    530530    char *flaws_str = NULL;
    531531
     532    int currline = 0;
     533    int copies = 0;
     534    int last_copy = 0;
     535
     536    /*@ buffetr ********************************************************* */
     537    char *curr_mountpoint = NULL;
     538
    532539    /*@ int ************************************************************** */
    533540    int i = 0;
     
    565572        }
    566573    }
    567     *res += look_for_duplicate_mountpoints(mountlist, flaws_str);
    568     return(flaws_str);
    569 }
    570 
    571 
    572 /**
    573  * Find the index number of @p device in the mountlist.
    574  * The device given must match @p mountlist->el[N].device exactly, case-sensitive.
    575  * @param mountlist The mountlist to search in.
    576  * @param device The device to search for.
    577  * @return The zero-based index of the device, or -1 if it could not be found.
    578  */
    579 int
    580 find_device_in_mountlist(struct mountlist_itself *mountlist, char *device)
    581 {
    582 
    583     /*@ int ************************************************************** */
    584     int i = 0;
    585 
    586     assert(mountlist != NULL);
    587     assert_string_is_neither_NULL_nor_zerolength(device);
    588     for (i = 0;
    589          i < mountlist->entries
    590          && strcmp(mountlist->el[i].device, device) != 0; i++);
    591 
    592     if (i == mountlist->entries) {
    593         return (-1);
    594     } else {
    595         return (i);
    596     }
    597 }
    598 
    599 
    600 /**
    601  * Look for duplicate mountpoints in @p mountlist.
    602  * @param mountlist The mountlist to check.
    603  * @param flaws_str The flaws string to append the results to.
    604  * @return The number of mountpoints that have duplicates, or 0 for success.
    605  */
    606 int
    607 look_for_duplicate_mountpoints(struct mountlist_itself *mountlist, char *flaws_str)
    608 {
    609 
    610     /*@ int ************************************************************* */
    611     int res = 0;
    612     int currline = 0;
    613     int i = 0;
    614     int copies = 0;
    615     int last_copy = 0;
    616 
    617     /*@ buffetr ********************************************************* */
    618     char *curr_mountpoint = NULL;
    619     char *tmp = NULL;
    620 
    621     assert(mountlist != NULL);
    622     assert(flaws_str != NULL);
     574
     575    /* Look for duplicate mountpoints in mountlist. */
    623576
    624577    for (currline = 0; currline < mountlist->entries; currline++) {
    625578        mr_asprintf(curr_mountpoint, "%s", mountlist->el[currline].mountpoint);
    626         for (i = 0, copies = 0, last_copy = -1; i < mountlist->entries;
    627              i++) {
     579        for (i = 0, copies = 0, last_copy = -1; i < mountlist->entries; i++) {
    628580            if (!strcmp(mountlist->el[i].mountpoint, curr_mountpoint)
    629581                && strcmp(mountlist->el[i].mountpoint, "lvm")
     
    639591            log_it(tmp);
    640592            mr_free(tmp);
    641             res++;
     593            (*res)++;
    642594        }
    643595        mr_free(curr_mountpoint);
    644596    }
    645     return (res);
     597
     598    return(flaws_str);
     599}
     600
     601
     602/**
     603 * Find the index number of @p device in the mountlist.
     604 * The device given must match @p mountlist->el[N].device exactly, case-sensitive.
     605 * @param mountlist The mountlist to search in.
     606 * @param device The device to search for.
     607 * @return The zero-based index of the device, or -1 if it could not be found.
     608 */
     609int
     610find_device_in_mountlist(struct mountlist_itself *mountlist, char *device)
     611{
     612
     613    /*@ int ************************************************************** */
     614    int i = 0;
     615
     616    assert(mountlist != NULL);
     617    assert_string_is_neither_NULL_nor_zerolength(device);
     618    for (i = 0;
     619         i < mountlist->entries
     620         && strcmp(mountlist->el[i].device, device) != 0; i++);
     621
     622    if (i == mountlist->entries) {
     623        return (-1);
     624    } else {
     625        return (i);
     626    }
    646627}
    647628
  • branches/2.2.10/mondo/src/common/libmondo-mountlist.h

    r2352 r2385  
    77int find_device_in_mountlist(struct mountlist_itself *mountlist,
    88                             char *device);
    9 int look_for_duplicate_mountpoints(struct mountlist_itself *mountlist,
    10                                    char *flaws_str);
    119int make_list_of_drives_in_mountlist(struct mountlist_itself *,
    1210                                     struct list_of_disks *);
  • branches/2.2.10/mondo/src/mondorestore/mondo-rstr-newt.h

    r2356 r2385  
    148148void log_file_end_to_screen(char *, char *);
    149149void log_to_screen(const char *fmt, ...);
    150 int look_for_duplicate_mountpoints(struct mountlist_itself *, char *);
    151150void make_list_of_unallocated_raid_partitions(struct mountlist_itself *,
    152151                                              struct mountlist_itself *,
Note: See TracChangeset for help on using the changeset viewer.