switch_ioscheduler(): only remove the last character if it's a newline
authorBart Van Assche <bart.vanassche@wdc.com>
Thu, 29 Mar 2018 15:30:38 +0000 (08:30 -0700)
committerBart Van Assche <bart.vanassche@wdc.com>
Thu, 29 Mar 2018 15:48:12 +0000 (08:48 -0700)
Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
backend.c

index fe335b5edbd1db3da837f095d1950a1408d3c256..f2d7cc368f0f63534218fc60e13d7ef895b0e3c5 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -1328,7 +1328,7 @@ static int init_io_u(struct thread_data *td)
 static int switch_ioscheduler(struct thread_data *td)
 {
 #ifdef FIO_HAVE_IOSCHED_SWITCH
 static int switch_ioscheduler(struct thread_data *td)
 {
 #ifdef FIO_HAVE_IOSCHED_SWITCH
-       char tmp[256], tmp2[128];
+       char tmp[256], tmp2[128], *p;
        FILE *f;
        int ret;
 
        FILE *f;
        int ret;
 
@@ -1372,9 +1372,11 @@ static int switch_ioscheduler(struct thread_data *td)
        }
        tmp[ret] = '\0';
        /*
        }
        tmp[ret] = '\0';
        /*
-        * either a list of io schedulers or "none\n" is expected.
+        * either a list of io schedulers or "none\n" is expected. Strip the
+        * trailing newline.
         */
         */
-       tmp[strlen(tmp) - 1] = '\0';
+       p = tmp;
+       strsep(&p, "\n");
 
        /*
         * Write to "none" entry doesn't fail, so check the result here.
 
        /*
         * Write to "none" entry doesn't fail, so check the result here.