Optimize the code that copies strings
[fio.git] / gclient.c
index 5087b6befc0557b2e354cc5b161d4edf80b5e06f..64324177ef1a8bb747346adf12f65a2e1a1de2b9 100644 (file)
--- a/gclient.c
+++ b/gclient.c
@@ -1,4 +1,4 @@
-#include <malloc.h>
+#include <stdlib.h>
 #include <string.h>
 
 #include <glib.h>
@@ -121,7 +121,7 @@ static void gfio_text_op(struct fio_client *client, struct fio_net_cmd *cmd)
        GtkTreeIter iter;
        struct tm *tm;
        time_t sec;
-       char tmp[64], timebuf[80];
+       char tmp[64], timebuf[96];
 
        sec = p->log_sec;
        tm = localtime(&sec);
@@ -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);
@@ -641,7 +641,7 @@ static void gfio_client_timed_out(struct fio_client *client)
        gdk_threads_leave();
 }
 
-static void gfio_client_stop(struct fio_client *client, struct fio_net_cmd *cmd)
+static void gfio_client_stop(struct fio_client *client)
 {
        struct gfio_client *gc = client->client_data;