Changeset 2301 in MondoRescue


Ignore:
Timestamp:
Jul 23, 2009, 7:52:12 PM (15 years ago)
Author:
Bruno Cornec
Message:
  • g_serial_string is managed dynamically
Location:
branches/2.2.10
Files:
3 edited

Legend:

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

    r2296 r2301  
    12131213    mr_asprintf(&data_disks_file, "%s/all.tar.gz", bkpinfo->tmpdir);
    12141214
    1215     snprintf(g_serial_string, MAX_STR_LEN - 8, "%s",
    1216              call_program_and_get_last_line_of_output("dd \
    1217 if=/dev/urandom bs=16 count=1 2> /dev/null | \
    1218 hexdump | tr -s ' ' '0' | head -n1"));
     1215    mr_sprintf(&g_serial_string, "%s", call_program_and_get_last_line_of_output("dd if=/dev/urandom bs=16 count=1 2> /dev/null | hexdump | tr -s ' ' '0' | head -n1"));
    12191216    strip_spaces(g_serial_string);
    1220     strcat(g_serial_string, "...word.");
     1217    mr_strcat(g_serial_string, "...word.");
    12211218    log_msg(2, "g_serial_string = '%s'", g_serial_string);
    1222     assert(strlen(g_serial_string) < MAX_STR_LEN);
    12231219
    12241220    mr_asprintf(&tmpfile, "%s/archives/SERIAL-STRING", bkpinfo->scratchdir);
     
    27642760        run_program_and_log_output(szunmount, 1);
    27652761        log_msg(2, "paafcd: cd_number = %d", cd_number);
    2766         log_msg(2, "our serial str = %s; g_serial_string = %s",
    2767                 our_serial_str, g_serial_string);
     2762        log_msg(2, "our serial str = %s; g_serial_string = %s", our_serial_str, g_serial_string);
    27682763        if (cd_number > 0 && !strcmp(our_serial_str, g_serial_string)) {
    27692764            mds = media_descriptor_string(g_backup_media_type);
  • branches/2.2.10/mondo/src/common/libmondo-tools.c

    r2296 r2301  
    3030
    3131extern int g_tape_buffer_size_MB;
    32 extern char *g_serial_string;
    3332extern bool g_text_mode;
    3433extern int g_currentY;
     
    13761375
    13771376/**
    1378  * If @p y, malloc @p x, else free @p x.
    1379  * @bug This function seems orphaned. Please remove.
    1380  */
    1381 #define do_alloc_or_free_depending(x,y) { if(y) {x=malloc(MAX_STR_LEN);} else {paranoid_free(x);} }
    1382 
    1383 /**
    13841377 * Allocate or free important globals, depending on @p mal.
    13851378 * @param mal If TRUE, malloc; if FALSE, free.
     
    13931386        malloc_string(g_tmpfs_mountpt);
    13941387        */
    1395         malloc_string(g_serial_string);
    13961388        malloc_string(g_magicdev_command);
    13971389    } else {
     
    14011393        paranoid_free(g_tmpfs_mountpt);
    14021394        */
    1403         paranoid_free(g_serial_string);
     1395        mr_free(g_serial_string);
    14041396        paranoid_free(g_magicdev_command);
    14051397
    14061398    }
    1407 
    1408     /*
    1409        char**list_of_arrays[] = {
    1410        &g_boot_mountpt,
    1411        &g_mondo_home,
    1412        &g_tmpfs_mountpt,
    1413        &g_serial_string,
    1414        &g_magicdev_command,
    1415        NULL};
    1416 
    1417        char**ppcurr;
    1418        int i;
    1419 
    1420        for(i=0;list_of_arrays[i];i++)
    1421        {
    1422        log_msg(5, "Allocating %d", i);
    1423        ppcurr = list_of_arrays[i];
    1424        if (mal)
    1425        { *ppcurr = malloc(MAX_STR_LEN); }
    1426        else
    1427        {
    1428        if (*ppcurr)
    1429        {
    1430        free(*ppcurr);
    1431        }
    1432        }
    1433        }
    1434        log_msg(5, "Returning");
    1435      */
    14361399}
    14371400
  • branches/2.2.10/tools/quality

    r2300 r2301  
    2929# How many sprintf/strcat/strcpy vs asprintf are they
    3030for s in asprintf mr_asprintf sprintf snprintf strcat strcpy strncpy fgets malloc mr_malloc malloc_string getline mr_getline MAX_STR_LEN getcwd goto free mr_free paranoid_free paranoid_system mr_system assert; do
    31     echo "monodrescue $s usage : "
     31    echo "mondorescue $s usage : "
    3232    tot=0
    3333    for i in `find . -name '*.c' -o -name '*.h' |  egrep -v '\.svn|/\*|monitas|mindi-busybox' | xargs grep -r -c -w $s | egrep -v ":0$"`; do
     
    4242pbg -w asprintf | grep -vE 'monitas|mindi-busybox|quality|/\*|asprintf\(&' > /tmp/mondo.quality
    4343cat /tmp/mondo.quality
    44 echo "monodrescue uses : `cat /tmp/mondo.quality | wc -l` asprintf without &"
     44echo "mondorescue uses : `cat /tmp/mondo.quality | wc -l` asprintf without &"
    4545pbg -w getline | grep -vE 'monitas|mindi-busybox|quality|/\*|getline\(&' > /tmp/mondo.quality
    4646cat /tmp/mondo.quality
    47 echo "monodrescue uses : `cat /tmp/mondo.quality | wc -l` getline without &"
     47echo "mondorescue uses : `cat /tmp/mondo.quality | wc -l` getline without &"
    4848pbg mr_asprintf | grep -vE '"|FNAME|ISOFS|syscall_sprintf|mr_mem|quality' > /tmp/mondo.quality
    4949cat /tmp/mondo.quality
    50 echo "monodrescue uses : `cat /tmp/mondo.quality | wc -l` mr_aspritnf without \""
     50echo "mondorescue uses : `cat /tmp/mondo.quality | wc -l` mr_aspritnf without \""
    5151echo " "
    5252echo "Splint: "
Note: See TracChangeset for help on using the changeset viewer.