diff mbox

[i-g-t,v3] libs/igt_core.c: Fix compile warnings in igt_core.c

Message ID 1432112431-28823-1-git-send-email-derek.j.morton@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Derek Morton May 20, 2015, 9 a.m. UTC
Fixed variables incorrectly declared as signed instead of unsigned.

v2: Addressed comments from Tim Gore
v3: Removed 'unused parameter' changes

Signed-off-by: Derek Morton <derek.j.morton@intel.com>
---
 lib/igt_core.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

Comments

Chris Wilson May 20, 2015, 9:09 a.m. UTC | #1
On Wed, May 20, 2015 at 10:00:31AM +0100, Derek Morton wrote:
> Fixed variables incorrectly declared as signed instead of unsigned.

Objection. If those array_sizes were larger than INT_MAX we have serious
problems. It would have been cleaner to keep the int (since you cast to
it anyway as the system interface is defined as int) but converted
the loop limits to int. ARRAY_SSIZE to borrow some nomeclature.

Or better yet, teach the compiler to not be so silly.
-Chris
diff mbox

Patch

diff --git a/lib/igt_core.c b/lib/igt_core.c
index 8a1a249..04da285 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -1104,7 +1104,7 @@  static pid_t helper_process_pids[] =
 
 static void reset_helper_process_list(void)
 {
-	for (int i = 0; i < ARRAY_SIZE(helper_process_pids); i++)
+	for (unsigned int i = 0; i < ARRAY_SIZE(helper_process_pids); i++)
 		helper_process_pids[i] = -1;
 	helper_process_count = 0;
 }
@@ -1122,7 +1122,7 @@  static int __waitpid(pid_t pid)
 static void fork_helper_exit_handler(int sig)
 {
 	/* Inside a signal handler, play safe */
-	for (int i = 0; i < ARRAY_SIZE(helper_process_pids); i++) {
+	for (unsigned int i = 0; i < ARRAY_SIZE(helper_process_pids); i++) {
 		pid_t pid = helper_process_pids[i];
 		if (pid != -1) {
 			kill(pid, SIGTERM);
@@ -1376,10 +1376,10 @@  static void restore_sig_handler(int sig_num)
 
 static void restore_all_sig_handler(void)
 {
-	int i;
+	unsigned int i;
 
 	for (i = 0; i < ARRAY_SIZE(orig_sig); i++)
-		restore_sig_handler(i);
+		restore_sig_handler((int)i);
 }
 
 static void call_exit_handlers(int sig)
@@ -1419,7 +1419,7 @@  static bool crash_signal(int sig)
 
 static void fatal_sig_handler(int sig)
 {
-	int i;
+	unsigned int i;
 
 	for (i = 0; i < ARRAY_SIZE(handled_signals); i++) {
 		if (handled_signals[i].number != sig)
@@ -1481,7 +1481,7 @@  static void fatal_sig_handler(int sig)
  */
 void igt_install_exit_handler(igt_exit_handler_t fn)
 {
-	int i;
+	unsigned int i;
 
 	for (i = 0; i < exit_handler_count; i++)
 		if (exit_handler_fn[i] == fn)
@@ -1521,7 +1521,7 @@  err:
 void igt_disable_exit_handler(void)
 {
 	sigset_t set;
-	int i;
+	unsigned int i;
 
 	if (exit_handler_disabled)
 		return;