Ignore:
Timestamp:
Jun 3, 2009, 7:10:19 PM (15 years ago)
Author:
Bruno Cornec
Message:

r3089@localhost: bruno | 2009-05-18 06:41:05 +0200

  • move call to asprintf to call to mr_asprintf (suppress a compiler warning)
  • remove all the most obvious bad call to strcat and replace by mr_strcat as appropriate
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.9/mondo/src/common/newt-specific.c

    r2136 r2211  
    1919
    2020#include "my-stuff.h"
     21#include "mr_mem.h"
    2122#include "mondostructures.h"
    2223#include "newt-specific.h"
     
    263264char *tmp1 = NULL;
    264265
    265     asprintf(&tmp,"ps %s | grep \" %s \" | awk '{print %s;}' | grep -v \"grep\"", ps_options, str , ps_proc_id);
     266    mr_asprintf(&tmp,"ps %s | grep \" %s \" | awk '{print %s;}' | grep -v \"grep\"", ps_options, str , ps_proc_id);
    266267    run_program_and_log_output(tmp, TRUE);
    267268    if (strlen(tmp) > 0) {
    268         asprintf(&tmp1,"kill `%s`", tmp);
     269        mr_asprintf(&tmp1,"kill `%s`", tmp);
    269270        run_program_and_log_output(tmp1, TRUE);
    270271        paranoid_free(tmp1);
     
    386387        run_program_and_log_output("umount " MNT_CDROM, FALSE);
    387388        if (g_selfmounted_isodir) {
    388             asprintf(&command, "umount %s", g_selfmounted_isodir);
     389            mr_asprintf(&command, "umount %s", g_selfmounted_isodir);
    389390            run_program_and_log_output(command, 1);
    390391            paranoid_free(command);
    391             asprintf(&command, "rmdir %s", g_selfmounted_isodir);
     392            mr_asprintf(&command, "rmdir %s", g_selfmounted_isodir);
    392393            run_program_and_log_output(command, 1);
    393394            paranoid_free(command);
     
    405406        printf("Type 'less %s' to see the output log\n", MONDO_LOGFILE);
    406407        if (strstr(bkpinfo->tmpdir ,"mondo.tmp.") != NULL) {
    407             asprintf(&command, "rm -Rf %s %s", bkpinfo->tmpdir, bkpinfo->scratchdir);
     408            mr_asprintf(&command, "rm -Rf %s %s", bkpinfo->tmpdir, bkpinfo->scratchdir);
    408409            system(command);
    409410            paranoid_free(command);
     
    956957        /*@ buffers ********************************************************** */
    957958        char *timeline_str;
    958         char *pcline_str;
    959         char *taskprogress;
     959        char *pcline_str = NULL;
     960        char *taskprogress = NULL;
    960961
    961962        /*@ int ************************************************************** */
     
    965966
    966967        malloc_string(timeline_str);
    967         malloc_string(pcline_str);
    968         malloc_string(taskprogress);
    969968        timeline_str[0] = '\0';
    970969//  log_it("update_eval_call_form called");
     
    997996                    time_remaining % 60);
    998997            if (percentage < 3) {
    999                 sprintf(pcline_str, " Working");
     998                mr_asprintf(&pcline_str, " Working");
    1000999                for (j = 0; j < g_mysterious_dot_counter; j++) {
    1001                     strcat(pcline_str, ".");
     1000                    mr_strcat(pcline_str, ".");
    10021001                }
    10031002                for (; j < 27; j++) {
    1004                     strcat(pcline_str, " ");
     1003                    mr_strcat(pcline_str, " ");
    10051004                }
    1006                 sprintf(pcline_str + strlen(pcline_str), " %c",
    1007                         special_dot_char(g_mysterious_dot_counter));
     1005                mr_strcat(pcline_str, " %c", special_dot_char(g_mysterious_dot_counter));
    10081006            } else {
    1009                 sprintf(pcline_str, " %3d%% done              %3d%% to go",
     1007                mr_asprintf(&pcline_str, " %3d%% done              %3d%% to go",
    10101008                        percentage, 100 - percentage);
    10111009            }
    10121010            if (g_text_mode) {
    1013                 sprintf(taskprogress, "TASK:  [");
     1011                mr_asprintf(&taskprogress, "TASK:  [");
    10141012                for (i = 0; i < percentage; i += 5) {
    1015                     strcat(taskprogress, "*");
     1013                    mr_strcat(taskprogress, "*");
    10161014                }
    10171015                for (; i < 100; i += 5) {
    1018                     strcat(taskprogress, ".");
     1016                    mr_strcat(taskprogress, ".");
    10191017                }
    10201018                if (percentage >= 3) {
    1021                     sprintf(taskprogress + strlen(taskprogress),
    1022                             "] %3d%% done; %2ld:%02ld to go", percentage,
     1019                    mr_strcat(taskprogress, "] %3d%% done; %2ld:%02ld to go", percentage,
    10231020                            time_remaining / 60, time_remaining % 60);
    10241021                    printf("---evalcall---1--- %s\n",
     
    10271024                    printf("---evalcall---E---\n");
    10281025                }
     1026                paranoid_free(taskprogress);
    10291027            } else {
    10301028                newtScaleSet(g_isoform_scale,
     
    10371035                }
    10381036            }
     1037            paranoid_free(pcline_str);
    10391038        }
    10401039        if (!g_text_mode) {
     
    10431042        }
    10441043        paranoid_free(timeline_str);
    1045         paranoid_free(pcline_str);
    1046         paranoid_free(taskprogress);
    10471044    }
    10481045
     
    10991096        char *percentline_str;
    11001097        char *timeline_str;
    1101         char *taskprogress;
     1098        char *taskprogress = NULL;
    11021099        char *tmp;
    11031100
     
    11051102        percentline_str = malloc(MAX_NEWT_COMMENT_LEN);
    11061103        timeline_str = malloc(MAX_NEWT_COMMENT_LEN);
    1107         taskprogress = malloc(MAX_NEWT_COMMENT_LEN);
    11081104        malloc_string(tmp);
    11091105        if (!g_text_mode) {
     
    11591155            printf("---progress-form---3--- %s\n", blurb3);
    11601156            printf("---progress-form---E---\n");
    1161             sprintf(taskprogress, "TASK:  [");
     1157            mr_asprintf(&taskprogress, "TASK:  [");
    11621158            for (i = 0; i < percentage; i += 5) {
    1163                 strcat(taskprogress, "*");
     1159                mr_strcat(taskprogress, "*");
    11641160            }
    11651161            for (; i < 100; i += 5) {
    1166                 strcat(taskprogress, ".");
     1162                mr_strcat(taskprogress, ".");
    11671163            }
    11681164            if (percentage > 100) {
    11691165                log_msg(2, "percentage = %d", percentage);
    11701166            }
    1171             sprintf(taskprogress + strlen(taskprogress),
    1172                     "] %3d%c", percentage, '%');
    1173             sprintf(taskprogress + strlen(taskprogress),
    1174                     " done; %2ld:%02ld to go",
     1167            mr_strcat(taskprogress, "] %3d%c", percentage, '%');
     1168            mr_strcat(taskprogress, " done; %2ld:%02ld to go",
    11751169                    time_remaining / 60, time_remaining % 60);
    11761170            printf("---progress-form---4--- %s\n", taskprogress);
     1171            paranoid_free(taskprogress);
    11771172        } else {
    11781173            center_string(blurb1, 54);
     
    11991194        paranoid_free(percentline_str);
    12001195        paranoid_free(timeline_str);
    1201         paranoid_free(taskprogress);
    12021196        paranoid_free(tmp);
    12031197    }
     
    14141408        }
    14151409
    1416         asprintf(&tmp1,"%s/icantfindthesefiles.txt",bkpinfo->tmpdir);
     1410        mr_asprintf(&tmp1,"%s/icantfindthesefiles.txt",bkpinfo->tmpdir);
    14171411        if (!(fout = fopen(tmp1, "a"))) {
    14181412            log_msg(2, "Can't write to %s", tmp1);
     
    15031497    char *filelist_entry_to_string(struct s_filelist_entry *flentry) {
    15041498        static char comment[100];
    1505         char *tmp;
     1499        char *tmp = NULL;
    15061500
    15071501        iamhere("entering");
    1508         malloc_string(tmp);
    15091502        assert(flentry != NULL);
    15101503        if (flentry->severity == 0) {
    1511             strcpy(tmp, "0   ");
     1504            mr_asprintf(&tmp, "0   ");
    15121505        } else if (flentry->severity == 1) {
    1513             strcpy(tmp, "low ");
     1506            mr_asprintf(&tmp, "low ");
    15141507        } else if (flentry->severity == 2) {
    1515             strcpy(tmp, "med ");
    1516         } else {
    1517             strcpy(tmp, "high");
    1518         }
    1519         strcat(tmp, "  ");
    1520         strncat(tmp, flentry->filename, 100);
    1521         tmp[98] = '\0';
    1522         strcpy(comment, tmp);
     1508            mr_asprintf(&tmp, "med ");
     1509        } else {
     1510            mr_asprintf(&tmp, "high");
     1511        }
     1512        mr_strcat(tmp, "  ");
     1513        mr_strcat(tmp, flentry->filename);
     1514        strncpy(comment, tmp, 99);
    15231515        paranoid_free(tmp);
     1516
    15241517        iamhere("leaving");
    15251518        return (comment);
Note: See TracChangeset for help on using the changeset viewer.