republic / cmockery

Automatically exported from code.google.com/p/cmockery
0 stars 0 forks source link

Integer conversion warning on HP-UX #10

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem on HP-UX?
1. execute "cc -c -I../include cmockery.c"

What is the expected output? What do you see instead?

Nothing should be printed. But it says:

"cmockery.c", line 1679: warning #2068-D: integer conversion resulted in a
          change of sign
                total_failed = -1;
                               ^

What version of the product are you using? On what operating system?

1. cmockery 0.1.2
2. HP-UX IA64

uname -a

HP-UX hpitv3 B.11.31 U ia64 0383467329 unlimited-user license

Please provide any additional information below.

Following patch removes this warning:

--- cmockery.c  Sat Aug 30 02:55:54 2008
+++ cmockery.c  Tue Jul 21 11:00:53 2009
@@ -1670,7 +1670,7 @@
    if (number_of_test_states) {
        print_error("Mismatched number of setup %d and teardown %d 
"
                    "functions\n", setups, teardowns);
-       total_failed = -1;
+       total_failed = (size_t)-1;
    }

    free(test_states);

Original issue reported on code.google.com by ade...@gmail.com on 21 Jul 2009 at 10:13

GoogleCodeExporter commented 9 years ago
I think it's clearer to use SIZE_MAX. Since this is a recent addition to std C, 
we need to provide it if it isn't 
already defined. So, put this after the #includes:

#ifndef SIZE_MAX
#define SIZE_MAX ((size_t)-1)
#endif

then the patch becomes:

-       total_failed = -1;
+       total_failed = SIZE_MAX;

Original comment by Stephen....@gmail.com on 16 Feb 2010 at 7:05

GoogleCodeExporter commented 9 years ago
Please feel free to commit this fix to the staging.

Original comment by ade...@gmail.com on 16 Feb 2010 at 9:52