All of lore.kernel.org
 help / color / mirror / Atom feed
From: Randy MacLeod <Randy.MacLeod@windriver.com>
To: <yocto@yoctoproject.org>, <anibal.limon@linaro.org>
Subject: [ptest-runner][PATCH 4/4] Fix additional warnings when using clang
Date: Wed, 17 Jul 2019 14:35:30 -0400	[thread overview]
Message-ID: <20190717183530.24893-4-Randy.MacLeod@windriver.com> (raw)
In-Reply-To: <20190717183530.24893-1-Randy.MacLeod@windriver.com>

Drop unused function parameters in wait_child().

The remaining warning in the top dir code is:
  utils.c:25:9: warning: macro name is a reserved identifier [-Wreserved-id-macro]
  #define _GNU_SOURCE
and it's not clear how to deal with that in a portable manner.

Drop unused variable in analizer code.
Rename analizer to analyzer.

Avoid program scope global by adding a set function for
the opts directory variable.

Free strdup()ed memory before exit.

Signed-off-by: Randy MacLeod <Randy.MacLeod@windriver.com>
---
 tests/main.c       | 13 ++++++++-----
 tests/ptest_list.c |  2 ++
 tests/utils.c      | 22 ++++++++++++++--------
 utils.c            |  6 ++----
 utils.h            |  2 ++
 5 files changed, 28 insertions(+), 17 deletions(-)

diff --git a/tests/main.c b/tests/main.c
index e1a8b69..1344bc0 100644
--- a/tests/main.c
+++ b/tests/main.c
@@ -38,14 +38,14 @@ static SuiteFunction *suites[] = {
 	NULL,
 };
 
+extern void set_opts_dir(char *);
+
 static inline void
 print_usage(FILE *stream, char *progname)
 {
 	fprintf(stream, "Usage: %s <-d directory>\n", progname);
 }
 
-char *opts_directory;
-
 int
 main(int argc, char *argv[])
 {
@@ -54,12 +54,12 @@ main(int argc, char *argv[])
 	int number_failed;
 	SuiteFunction *sf;
 
-	opts_directory = NULL;
+	char *opts_dir = NULL;
 
 	while ((opt = getopt(argc, argv, "d:t:h")) != -1) {
 		switch (opt) {
 			case 'd':
-				opts_directory = strdup(optarg);
+				opts_dir = strdup(optarg);
 			break;
 			case 'h':
 				/* fall though !! */
@@ -69,10 +69,11 @@ main(int argc, char *argv[])
 		}
 	}
 
-	if (opts_directory == NULL) {
+	if (opts_dir == NULL) {
 		print_usage(stdout, argv[0]);
 		exit(1);
 	}
+	set_opts_dir(opts_dir);
 
 	i = 0;
 	number_failed = 0;
@@ -88,6 +89,8 @@ main(int argc, char *argv[])
 		i++;
 		sf = suites[i];
 	}
+	set_opts_dir(NULL);
+	free(opts_dir);
 
 	return number_failed;
 }
diff --git a/tests/ptest_list.c b/tests/ptest_list.c
index e0ec276..081f027 100644
--- a/tests/ptest_list.c
+++ b/tests/ptest_list.c
@@ -29,6 +29,8 @@
 
 #include "ptest_list.h"
 
+extern Suite *ptest_list_suite(void);
+
 static int ptests_num = 6;
 static char *ptest_names[] = {
 	"python",
diff --git a/tests/utils.c b/tests/utils.c
index 571d488..4fa4609 100644
--- a/tests/utils.c
+++ b/tests/utils.c
@@ -32,9 +32,15 @@
 #include "ptest_list.h"
 #include "utils.h"
 
+Suite *utils_suite(void);
+
 #define PRINT_PTEST_BUF_SIZE 8192
 
-extern char *opts_directory;
+static char *opts_directory = NULL;
+
+void set_opts_dir(char * od) {
+	opts_directory = od;
+}
 
 static char *ptests_found[] = {
 	"bash",
@@ -68,7 +74,7 @@ find_word(int *found, const char *line, const char *word)
 }
 
 static void test_ptest_expected_failure(struct ptest_list *, const int, char *,
-	void (*h_analizer)(const int, FILE *, FILE *));
+	void (*h_analyzer)(const int, FILE *));
 
 START_TEST(test_get_available_ptests)
 {
@@ -189,7 +195,7 @@ START_TEST(test_run_ptests)
 END_TEST
 
 static void
-search_for_timeout_and_duration(const int rp, FILE *fp_stdout, FILE *fp_stderr)
+search_for_timeout_and_duration(const int rp, FILE *fp_stdout)
 {
 	const char *timeout_str = "TIMEOUT";
 	const char *duration_str = "DURATION";
@@ -218,7 +224,7 @@ START_TEST(test_run_timeout_duration_ptest)
 END_TEST
 
 static void
-search_for_fail(const int rp, FILE *fp_stdout, FILE *fp_stderr)
+search_for_fail(const int rp, FILE *fp_stdout)
 {
         const char *fail_str = "ERROR: Exit status is";
         char line_buf[PRINT_PTEST_BUF_SIZE];
@@ -284,7 +290,7 @@ START_TEST(test_xml_fail)
 END_TEST
 
 Suite *
-utils_suite()
+utils_suite(void)
 {
 	Suite *s;
 	TCase *tc_core;
@@ -308,7 +314,7 @@ utils_suite()
 
 static void
 test_ptest_expected_failure(struct ptest_list *head, const int timeout, char *progname,
-		void (*h_analizer)(const int, FILE *, FILE *))
+		void (*h_analyzer)(const int, FILE *))
 {
 	char *buf_stdout;
 	size_t size_stdout = PRINT_PTEST_BUF_SIZE;
@@ -329,9 +335,9 @@ test_ptest_expected_failure(struct ptest_list *head, const int timeout, char *pr
 		struct ptest_options opts = EmptyOpts;
 		opts.timeout = timeout;
 
-		h_analizer(
+		h_analyzer(
 			run_ptests(filtered, opts, progname, fp_stdout, fp_stderr),
-			fp_stdout, fp_stderr
+			fp_stdout
 		);
 
 		PTEST_LIST_FREE_ALL_CLEAN(filtered);
diff --git a/utils.c b/utils.c
index 92654bf..a8ba190 100644
--- a/utils.c
+++ b/utils.c
@@ -288,8 +288,7 @@ run_child(char *run_ptest, int fd_stdout, int fd_stderr)
 }
 
 static inline int
-wait_child(const char *ptest_dir, const char *run_ptest, pid_t pid,
-		int timeout, int *fds, FILE **fps, int *timeouted)
+wait_child(pid_t pid, int timeout, int *fds, FILE **fps, int *timeouted)
 {
 	struct pollfd pfds[2];
 	struct timespec sentinel;
@@ -490,8 +489,7 @@ run_ptests(struct ptest_list *head, const struct ptest_options opts,
 				fprintf(fp, "%s\n", get_stime(stime, GET_STIME_BUF_SIZE, sttime));
 				fprintf(fp, "BEGIN: %s\n", ptest_dir);
 
-				status = wait_child(ptest_dir, p->run_ptest, child,
-						opts.timeout, fds, fps, &timeouted);
+				status = wait_child(child, opts.timeout, fds, fps, &timeouted);
 				entime = time(NULL);
 				duration = entime - sttime;
 
diff --git a/utils.h b/utils.h
index f6a56f1..aa53707 100644
--- a/utils.h
+++ b/utils.h
@@ -53,4 +53,6 @@ extern FILE *xml_create(int, char *);
 extern void xml_add_case(FILE *, int, const char *, int, int);
 extern void xml_finish(FILE *);
 
+void set_opts_dir(char * od);
+
 #endif
-- 
2.17.0



  parent reply	other threads:[~2019-07-17 18:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-17 18:35 [ptest-runner][PATCH 1/4] utils: ensure child can be session leader Randy MacLeod
2019-07-17 18:35 ` [ptest-runner][PATCH 2/4] main code: fix clang warnings Randy MacLeod
2019-07-17 18:35 ` [ptest-runner][PATCH 3/4] tests: " Randy MacLeod
2019-07-17 18:35 ` Randy MacLeod [this message]
2019-08-01 18:19   ` [ptest-runner][PATCH 4/4] Fix additional warnings when using clang Anibal Limon
2019-08-01 18:34     ` Randy MacLeod
2019-07-21 19:22 ` [ptest-runner][PATCH 1/4] utils: ensure child can be session leader Anibal Limon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190717183530.24893-4-Randy.MacLeod@windriver.com \
    --to=randy.macleod@windriver.com \
    --cc=anibal.limon@linaro.org \
    --cc=yocto@yoctoproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.