diff options
author | Michael J. Chudobiak <mjc@avtechpulse.com> | 2012-11-13 14:38:45 -0500 |
---|---|---|
committer | Michael J. Chudobiak <mjc@avtechpulse.com> | 2012-11-13 14:38:45 -0500 |
commit | 6e830a9d20940d97acdf9d5adbfdb540a8f0e25c (patch) | |
tree | cd650d66f0fb1a51da6046869575bf938ad910b0 | |
parent | 4326512568e8ab96f90844e26e10f0b50ce9c733 (diff) |
remove some fixed length self-cal strings
-rw-r--r-- | device-functions.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/device-functions.c b/device-functions.c index b646b43..9c641c0 100644 --- a/device-functions.c +++ b/device-functions.c @@ -4026,10 +4026,9 @@ int go_cal(CalStruct *caldata) void cal_string(char *parameter, CalStruct *caldata) { - char string[max_output_length]; - - sprintf(string,"CH%d %s cal: %d errors. Adj: %6.2f%% max, %6.2f%% avg.\r\n", caldata->channel+1,parameter, caldata->error, caldata->max_change, caldata->avg_change); + gchar *string = g_strdup_printf ("CH%d %s cal: %d errors. Adj: %6.2f%% max, %6.2f%% avg.\r\n", caldata->channel+1,parameter, caldata->error, caldata->max_change, caldata->avg_change); strcat (caldata->response, string); + g_free (string); } @@ -4042,7 +4041,7 @@ int self_cal() int do_full_self_cal(CalStruct *caldata) { - char string[LCD_cols+1]; + gchar *string; long start_timer, diff_timer; int eprom_loc; @@ -4050,8 +4049,10 @@ int do_full_self_cal(CalStruct *caldata) LCD_clear(); /*0123456789012345678901234567890123456789*/ LCD_write(0,0,"Self-calibration in progress."); /*0123456789012345678901234567890123456789*/ - sprintf(string,"Typical run time: %d min, %d sec.", globals.Flash.self_cal_typical_time_min, globals.Flash.self_cal_typical_time_sec); + + string = g_strdup_printf ("Typical run time: %d min, %d sec.", globals.Flash.self_cal_typical_time_min, globals.Flash.self_cal_typical_time_sec); LCD_write(1,0,string); + g_free (string); while ((sec_timer() - globals.Timers.startup_timer_value) < (long)globals.Flash.self_cal_pause) { /*0123456789012345678901234567890123456789*/ @@ -4099,8 +4100,11 @@ int do_full_self_cal(CalStruct *caldata) LCD_clear(); /*0123456789012345678901234567890123456789*/ LCD_write(0,0,"Self-calibration complete."); - sprintf (string, "%d errors. Max change: %6.2f%%", caldata->total_errors, caldata->total_max_change); + + string = g_strdup_printf ("%d errors. Max change: %6.2f%%", caldata->total_errors, caldata->total_max_change); LCD_write(1,0,string); + g_free (string); + LCD_write(2,0,"More details are provided by \"cal?\""); g_usleep (3e6); @@ -4111,9 +4115,9 @@ int do_full_self_cal(CalStruct *caldata) globals.Flash.self_cal_typical_time_min = (int) (diff_timer / 60); globals.Flash.self_cal_typical_time_sec = (int) (diff_timer % 60); - // FIXME - cpp buffer error, due to evil fixed-length strings - sprintf(string,"Completed in %d minutes and %d seconds\r\n", globals.Flash.self_cal_typical_time_min, globals.Flash.self_cal_typical_time_sec); + string = g_strdup_printf ("Completed in %d minutes and %d seconds\r\n", globals.Flash.self_cal_typical_time_min, globals.Flash.self_cal_typical_time_sec); strcat (caldata->response, string); + g_free (string); eprom_loc = (char *) &(globals.Flash.self_cal_typical_time_min) - (char *) &(globals.Flash.flash_start); writeUserBlock(&globals.Flash, eprom_loc, sizeof(globals.Flash.self_cal_typical_time_min)); |