cyclictest: Fix compiler warning about srncpy output truncated
PATCH 1/2 cyclictest: Fix compiler warning about srncpy output truncated
From: Clark Williams <[email protected]>
Fix compiler warning about strncpy output truncated before terminating nul copying as many bytes from a string as its length
Signed-off-by Clark Williams <[email protected]>
Signed-off-by John Kacur <[email protected]>
Extracted from a patch from Clark
--- src/cyclictest/cyclictest.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
src/cyclictest/cyclictest.c +2 -2
@@ -1257,7 +1257,7 @@ static void process_options (int argc, char *argv[], int max_cpus)case 'F' :case OPT_FIFO : use_fifo =1 ; -strncpy (fifopath, optarg,strlen (optarg)); +strncpy (fifopath, optarg,strnlen (optarg,MAX_PATH -1 ));break ;case 'H' :case OPT_HISTOFALL :
@@ -1267,7 +1267,7 @@ static void process_options (int argc, char *argv[], int max_cpus) histogram =atoi (optarg);break ;case OPT_HISTFILE : use_histfile =1 ; -strncpy (histfile, optarg,strlen (optarg)); +strncpy (histfile, optarg,strnlen (optarg,MAX_PATH -1 ));break ;case 'i' :case OPT_INTERVAL :
Signature · 1 line
2.20.1
PATCH 2/2 cyclictest: Make sure affinity is respected when numa is detected
Make sure affinity is respected when numa is automatically detected and when smp is not specified. Don't break the way smp currently works.
Signed-off-by John Kacur <[email protected]>
--- src/cyclictest/cyclictest.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
src/cyclictest/cyclictest.c +6 -7
@@ -1218,7 +1218,7 @@ static void process_options (int argc, char *argv[], int max_cpus)case 'a' :case OPT_AFFINITY : option_affinity =1 ; -if (smp || numa) +if (smp)break ;if (optarg !=NULL ) {parse_cpumask (optarg, max_cpus);
@@ -1384,8 +1384,10 @@ static void process_options (int argc, char *argv[], int max_cpus)#ifdef NUMA if (numa_available () !=-1 ) { numa =1 ; - num_threads = max_cpus; - setaffinity =AFFINITY_USEALL ; +if (setaffinity ==AFFINITY_UNSPECIFIED ) { + num_threads = max_cpus; + setaffinity =AFFINITY_USEALL ; + } }#else warn ("cyclictest was not built with the numa option\n" );
@@ -1394,11 +1396,8 @@ static void process_options (int argc, char *argv[], int max_cpus) }if (option_affinity) { -if (smp) { +if (smp)warn ("-a ignored due to smp mode\n" ); - }else if (numa) { -warn ("-a ignored due to numa mode\n" ); - } }if (smi) {
Signature · 1 line
2.20.1