Optimize the code that copies strings
[fio.git] / gclient.c
index 04275a1384c21ee74f44d13912c282c77660e65d..64324177ef1a8bb747346adf12f65a2e1a1de2b9 100644 (file)
--- a/gclient.c
+++ b/gclient.c
@@ -318,7 +318,7 @@ static void gfio_update_thread_status(struct gui_entry *ge,
        static char message[100];
        const char *m = message;
 
-       strncpy(message, status_message, sizeof(message) - 1);
+       snprintf(message, sizeof(message), "%s", status_message);
        gtk_progress_bar_set_text(GTK_PROGRESS_BAR(ge->thread_status_pb), m);
        gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ge->thread_status_pb), perc / 100.0);
        gtk_widget_queue_draw(ge->ui->window);
@@ -330,7 +330,7 @@ static void gfio_update_thread_status_all(struct gui *ui, char *status_message,
        static char message[100];
        const char *m = message;
 
-       strncpy(message, status_message, sizeof(message) - 1);
+       strncpy(message, sizeof(message), "%s", status_message);
        gtk_progress_bar_set_text(GTK_PROGRESS_BAR(ui->thread_status_pb), m);
        gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ui->thread_status_pb), perc / 100.0);
        gtk_widget_queue_draw(ui->window);