[PATCH] Convert hex literal to signed int

Maarten Bosmans mkbosmans at gmail.com
Wed Sep 21 04:53:44 PDT 2011


GCC issues a warning: comparison between signed and unsigned integer expressions.
This is because the (positive) literal does not fit in an int, so the next bigger integer is used: unsigned int.
The cast makes an int out of the literal again.
---
 orc/orcemulateopcodes.c |    4 ++--
 orc/orcprogram-c.c      |    4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/orc/orcemulateopcodes.c b/orc/orcemulateopcodes.c
index c467aa0..a33b06c 100644
--- a/orc/orcemulateopcodes.c
+++ b/orc/orcemulateopcodes.c
@@ -4870,7 +4870,7 @@ emulate_convfl (OrcOpcodeExecutor *ex, int offset, int n)
     {
        int tmp;
        tmp = (int)var32.f;
-       if (tmp == 0x80000000 && !(var32.i&0x80000000)) tmp = 0x7fffffff;
+       if (tmp == (int)0x80000000 && !(var32.i&0x80000000)) tmp = 0x7fffffff;
        var33.i = tmp;
     }
     /* 2: storel */
@@ -5280,7 +5280,7 @@ emulate_convdl (OrcOpcodeExecutor *ex, int offset, int n)
     {
        int tmp;
        tmp = var32.f;
-       if (tmp == 0x80000000 && !(var32.i & ORC_UINT64_C(0x8000000000000000))) tmp = 0x7fffffff;
+       if (tmp == (int)0x80000000 && !(var32.i & ORC_UINT64_C(0x8000000000000000))) tmp = 0x7fffffff;
        var33.i = tmp;
     }
     /* 2: storel */
diff --git a/orc/orcprogram-c.c b/orc/orcprogram-c.c
index dac0fe6..63298e7 100644
--- a/orc/orcprogram-c.c
+++ b/orc/orcprogram-c.c
@@ -1276,7 +1276,7 @@ c_rule_convfl (OrcCompiler *p, void *user, OrcInstruction *insn)
   ORC_ASM_CODE(p, "    {\n");
   ORC_ASM_CODE(p,"       int tmp;\n");
   ORC_ASM_CODE(p,"       tmp = (int)%s;\n", src);
-  ORC_ASM_CODE(p,"       if (tmp == 0x80000000 && !(%s&0x80000000)) tmp = 0x7fffffff;\n", src_i);
+  ORC_ASM_CODE(p,"       if (tmp == (int)0x80000000 && !(%s&0x80000000)) tmp = 0x7fffffff;\n", src_i);
   ORC_ASM_CODE(p,"       %s = tmp;\n", dest);
   ORC_ASM_CODE(p, "    }\n");
 }
@@ -1293,7 +1293,7 @@ c_rule_convdl (OrcCompiler *p, void *user, OrcInstruction *insn)
   ORC_ASM_CODE(p, "    {\n");
   ORC_ASM_CODE(p,"       int tmp;\n");
   ORC_ASM_CODE(p,"       tmp = %s;\n", src);
-  ORC_ASM_CODE(p,"       if (tmp == 0x80000000 && !(%s & ORC_UINT64_C(0x8000000000000000))) tmp = 0x7fffffff;\n", src_i);
+  ORC_ASM_CODE(p,"       if (tmp == (int)0x80000000 && !(%s & ORC_UINT64_C(0x8000000000000000))) tmp = 0x7fffffff;\n", src_i);
   ORC_ASM_CODE(p,"       %s = tmp;\n", dest);
   ORC_ASM_CODE(p, "    }\n");
 }
-- 
1.7.4.1



More information about the gstreamer-devel mailing list