[Forensics-changes] [yara] 47/368: Fix warnings "implicit conversion shortens 64-bit value into a 32-bit value"

Hilko Bengen bengen at moszumanska.debian.org
Sat Jul 1 10:30:10 UTC 2017


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to annotated tag v3.5.0
in repository yara.

commit f502bdf4903545cfc75dfe15bed650138da53a81
Author: Victor M. Alvarez <plusvic at gmail.com>
Date:   Fri Sep 11 16:15:18 2015 +0200

    Fix warnings "implicit conversion shortens 64-bit value into a 32-bit value"
---
 libyara/Makefile.am             |   3 +-
 libyara/arena.c                 |   4 +-
 libyara/atoms.c                 |   2 +-
 libyara/exec.c                  |   4 +-
 libyara/grammar.c               | 360 ++++++++++++++++------------------------
 libyara/grammar.y               | 126 ++++----------
 libyara/hash.c                  |   4 +-
 libyara/hex_grammar.c           |  14 +-
 libyara/hex_grammar.h           |   2 +-
 libyara/hex_grammar.y           |  14 +-
 libyara/include/yara/arena.h    |   6 +-
 libyara/include/yara/parser.h   |   4 +-
 libyara/include/yara/sizedstr.h |   4 +-
 libyara/include/yara/types.h    |   2 +-
 libyara/object.c                |   2 +-
 libyara/parser.c                |   6 +-
 libyara/re.c                    |   2 +-
 libyara/scan.c                  |  20 ++-
 libyara/sizedstr.c              |   2 +-
 libyara/strutils.c              |   4 +-
 yara.c                          |   2 +-
 21 files changed, 226 insertions(+), 361 deletions(-)

diff --git a/libyara/Makefile.am b/libyara/Makefile.am
index 049dccc..9de1ded 100644
--- a/libyara/Makefile.am
+++ b/libyara/Makefile.am
@@ -24,7 +24,8 @@ endif
 
 AM_YFLAGS=-d
 
-AM_CFLAGS=-O3 -Wall -Wno-deprecated-declarations -std=gnu99 -I$(srcdir)/include
+AM_CFLAGS=-O3 -Wall -Wno-deprecated-declarations -Wstrict-prototypes \
+  -Wshorten-64-to-32 -std=gnu99 -I$(srcdir)/include
 
 if GCC
 AM_CFLAGS+=-fvisibility=hidden
diff --git a/libyara/arena.c b/libyara/arena.c
index 7f70bb4..5fda13a 100644
--- a/libyara/arena.c
+++ b/libyara/arena.c
@@ -42,7 +42,7 @@ from files.
 typedef struct _ARENA_FILE_HEADER
 {
   char      magic[4];
-  uint32_t  size;
+  uint64_t  size;
   uint8_t   version;
 
 } ARENA_FILE_HEADER;
@@ -340,7 +340,7 @@ void* yr_arena_base_address(
 void* yr_arena_next_address(
   YR_ARENA* arena,
   void* address,
-  int offset)
+  size_t offset)
 {
   YR_ARENA_PAGE* page;
 
diff --git a/libyara/atoms.c b/libyara/atoms.c
index fa21036..5a3bbcd 100644
--- a/libyara/atoms.c
+++ b/libyara/atoms.c
@@ -1120,7 +1120,7 @@ int yr_atoms_extract_from_re(
 
 int yr_atoms_extract_from_string(
     uint8_t* string,
-    int string_length,
+    int32_t string_length,
     int flags,
     YR_ATOM_LIST_ITEM** atoms)
 {
diff --git a/libyara/exec.c b/libyara/exec.c
index 6133972..6cb25ca 100644
--- a/libyara/exec.c
+++ b/libyara/exec.c
@@ -491,7 +491,7 @@ int yr_execute_code(
         ensure_defined(r1);
         assert(r2.o->type == OBJECT_TYPE_ARRAY);
 
-        r1.o = yr_object_array_get_item(r2.o, 0, r1.i);
+        r1.o = yr_object_array_get_item(r2.o, 0, (int) r1.i);
 
         if (r1.o == NULL)
           r1.i = UNDEFINED;
@@ -519,7 +519,7 @@ int yr_execute_code(
         args_fmt = *(char**)(ip + 1);
         ip += sizeof(uint64_t);
 
-        i = strlen(args_fmt);
+        i = (int) strlen(args_fmt);
         count = 0;
 
         // pop arguments from stack and copy them to args array
diff --git a/libyara/grammar.c b/libyara/grammar.c
index 323a79c..5daf0cb 100644
--- a/libyara/grammar.c
+++ b/libyara/grammar.c
@@ -624,17 +624,17 @@ static const yytype_int8 yyrhs[] =
 static const yytype_uint16 yyrline[] =
 {
        0,   197,   197,   199,   200,   201,   202,   203,   208,   221,
-     220,   250,   253,   281,   284,   311,   316,   317,   322,   323,
-     329,   332,   350,   363,   400,   401,   406,   422,   435,   448,
-     465,   466,   471,   485,   484,   503,   520,   521,   526,   527,
-     528,   529,   534,   625,   674,   734,   781,   782,   786,   811,
-     847,   893,   910,   919,   928,   943,   957,   971,   987,  1002,
-    1038,  1001,  1154,  1153,  1233,  1239,  1246,  1245,  1306,  1305,
-    1364,  1373,  1382,  1391,  1400,  1409,  1418,  1422,  1430,  1431,
-    1436,  1458,  1470,  1486,  1485,  1491,  1500,  1501,  1506,  1511,
-    1520,  1521,  1525,  1533,  1537,  1547,  1561,  1577,  1587,  1596,
-    1620,  1635,  1650,  1673,  1688,  1711,  1755,  1774,  1792,  1810,
-    1828,  1854,  1872,  1882,  1892,  1902,  1912,  1922,  1932
+     220,   245,   248,   276,   279,   306,   311,   312,   317,   318,
+     324,   327,   345,   358,   395,   396,   401,   417,   430,   443,
+     460,   461,   466,   477,   476,   492,   506,   507,   512,   513,
+     514,   515,   520,   605,   651,   706,   750,   751,   755,   780,
+     816,   862,   877,   886,   895,   910,   922,   936,   949,   961,
+     991,   960,  1107,  1106,  1186,  1192,  1199,  1198,  1259,  1258,
+    1317,  1326,  1335,  1344,  1353,  1362,  1371,  1375,  1383,  1384,
+    1389,  1411,  1423,  1439,  1438,  1444,  1453,  1454,  1459,  1464,
+    1473,  1474,  1478,  1486,  1490,  1500,  1514,  1530,  1540,  1549,
+    1573,  1585,  1597,  1613,  1625,  1641,  1685,  1704,  1722,  1740,
+    1758,  1784,  1802,  1812,  1822,  1832,  1842,  1852,  1862
 };
 #endif
 
@@ -1795,12 +1795,7 @@ yyreduce:
 #line 221 "grammar.y"
     {
         YR_RULE* rule = yr_parser_reduce_rule_declaration_phase_1(
-            yyscanner,
-            (yyvsp[(1) - (7)].integer),
-            (yyvsp[(3) - (7)].c_string),
-            (yyvsp[(4) - (7)].c_string),
-            (yyvsp[(7) - (7)].string),
-            (yyvsp[(6) - (7)].meta));
+            yyscanner, (int32_t) (yyvsp[(1) - (7)].integer), (yyvsp[(3) - (7)].c_string), (yyvsp[(4) - (7)].c_string), (yyvsp[(7) - (7)].string), (yyvsp[(6) - (7)].meta));
 
         ERROR_IF(rule == NULL);
 
@@ -1809,7 +1804,7 @@ yyreduce:
     break;
 
   case 10:
-#line 235 "grammar.y"
+#line 230 "grammar.y"
     {
         YR_RULE* rule = (yyvsp[(8) - (10)].rule); // rule created in phase 1
 
@@ -1823,14 +1818,14 @@ yyreduce:
     break;
 
   case 11:
-#line 250 "grammar.y"
+#line 245 "grammar.y"
     {
         (yyval.meta) = NULL;
       }
     break;
 
   case 12:
-#line 254 "grammar.y"
+#line 249 "grammar.y"
     {
         // Each rule have a list of meta-data info, consisting in a
         // sequence of YR_META structures. The last YR_META structure does
@@ -1856,14 +1851,14 @@ yyreduce:
     break;
 
   case 13:
-#line 281 "grammar.y"
+#line 276 "grammar.y"
     {
         (yyval.string) = NULL;
       }
     break;
 
   case 14:
-#line 285 "grammar.y"
+#line 280 "grammar.y"
     {
         // Each rule have a list of strings, consisting in a sequence
         // of YR_STRING structures. The last YR_STRING structure does not
@@ -1889,34 +1884,34 @@ yyreduce:
     break;
 
   case 16:
-#line 316 "grammar.y"
+#line 311 "grammar.y"
     { (yyval.integer) = 0;  }
     break;
 
   case 17:
-#line 317 "grammar.y"
+#line 312 "grammar.y"
     { (yyval.integer) = (yyvsp[(1) - (2)].integer) | (yyvsp[(2) - (2)].integer); }
     break;
 
   case 18:
-#line 322 "grammar.y"
+#line 317 "grammar.y"
     { (yyval.integer) = RULE_GFLAGS_PRIVATE; }
     break;
 
   case 19:
-#line 323 "grammar.y"
+#line 318 "grammar.y"
     { (yyval.integer) = RULE_GFLAGS_GLOBAL; }
     break;
 
   case 20:
-#line 329 "grammar.y"
+#line 324 "grammar.y"
     {
         (yyval.c_string) = NULL;
       }
     break;
 
   case 21:
-#line 333 "grammar.y"
+#line 328 "grammar.y"
     {
         // Tags list is represented in the arena as a sequence
         // of null-terminated strings, the sequence ends with an
@@ -1933,7 +1928,7 @@ yyreduce:
     break;
 
   case 22:
-#line 351 "grammar.y"
+#line 346 "grammar.y"
     {
         char* identifier;
 
@@ -1949,7 +1944,7 @@ yyreduce:
     break;
 
   case 23:
-#line 364 "grammar.y"
+#line 359 "grammar.y"
     {
         char* tag_name = (yyvsp[(1) - (2)].c_string);
         size_t tag_length = tag_name != NULL ? strlen(tag_name) : 0;
@@ -1984,17 +1979,17 @@ yyreduce:
     break;
 
   case 24:
-#line 400 "grammar.y"
+#line 395 "grammar.y"
     {  (yyval.meta) = (yyvsp[(1) - (1)].meta); }
     break;
 
   case 25:
-#line 401 "grammar.y"
+#line 396 "grammar.y"
     {  (yyval.meta) = (yyvsp[(1) - (2)].meta); }
     break;
 
   case 26:
-#line 407 "grammar.y"
+#line 402 "grammar.y"
     {
         SIZED_STRING* sized_string = (yyvsp[(3) - (3)].sized_string);
 
@@ -2013,7 +2008,7 @@ yyreduce:
     break;
 
   case 27:
-#line 423 "grammar.y"
+#line 418 "grammar.y"
     {
         (yyval.meta) = yr_parser_reduce_meta_declaration(
             yyscanner,
@@ -2029,7 +2024,7 @@ yyreduce:
     break;
 
   case 28:
-#line 436 "grammar.y"
+#line 431 "grammar.y"
     {
         (yyval.meta) = yr_parser_reduce_meta_declaration(
             yyscanner,
@@ -2045,7 +2040,7 @@ yyreduce:
     break;
 
   case 29:
-#line 449 "grammar.y"
+#line 444 "grammar.y"
     {
         (yyval.meta) = yr_parser_reduce_meta_declaration(
             yyscanner,
@@ -2061,23 +2056,20 @@ yyreduce:
     break;
 
   case 30:
-#line 465 "grammar.y"
+#line 460 "grammar.y"
     { (yyval.string) = (yyvsp[(1) - (1)].string); }
     break;
 
   case 31:
-#line 466 "grammar.y"
+#line 461 "grammar.y"
     { (yyval.string) = (yyvsp[(1) - (2)].string); }
     break;
 
   case 32:
-#line 472 "grammar.y"
+#line 467 "grammar.y"
     {
         (yyval.string) = yr_parser_reduce_string_declaration(
-            yyscanner,
-            (yyvsp[(4) - (4)].integer),
-            (yyvsp[(1) - (4)].c_string),
-            (yyvsp[(3) - (4)].sized_string));
+            yyscanner, (int32_t) (yyvsp[(4) - (4)].integer), (yyvsp[(1) - (4)].c_string), (yyvsp[(3) - (4)].sized_string));
 
         yr_free((yyvsp[(1) - (4)].c_string));
         yr_free((yyvsp[(3) - (4)].sized_string));
@@ -2087,20 +2079,17 @@ yyreduce:
     break;
 
   case 33:
-#line 485 "grammar.y"
+#line 477 "grammar.y"
     {
         compiler->error_line = yyget_lineno(yyscanner);
       }
     break;
 
   case 34:
-#line 489 "grammar.y"
+#line 481 "grammar.y"
     {
         (yyval.string) = yr_parser_reduce_string_declaration(
-            yyscanner,
-            (yyvsp[(5) - (5)].integer) | STRING_GFLAGS_REGEXP,
-            (yyvsp[(1) - (5)].c_string),
-            (yyvsp[(4) - (5)].sized_string));
+            yyscanner, (int32_t) (yyvsp[(5) - (5)].integer) | STRING_GFLAGS_REGEXP, (yyvsp[(1) - (5)].c_string), (yyvsp[(4) - (5)].sized_string));
 
         yr_free((yyvsp[(1) - (5)].c_string));
         yr_free((yyvsp[(4) - (5)].sized_string));
@@ -2112,13 +2101,10 @@ yyreduce:
     break;
 
   case 35:
-#line 504 "grammar.y"
+#line 493 "grammar.y"
     {
         (yyval.string) = yr_parser_reduce_string_declaration(
-            yyscanner,
-            STRING_GFLAGS_HEXADECIMAL,
-            (yyvsp[(1) - (3)].c_string),
-            (yyvsp[(3) - (3)].sized_string));
+            yyscanner, STRING_GFLAGS_HEXADECIMAL, (yyvsp[(1) - (3)].c_string), (yyvsp[(3) - (3)].sized_string));
 
         yr_free((yyvsp[(1) - (3)].c_string));
         yr_free((yyvsp[(3) - (3)].sized_string));
@@ -2128,37 +2114,37 @@ yyreduce:
     break;
 
   case 36:
-#line 520 "grammar.y"
+#line 506 "grammar.y"
     { (yyval.integer) = 0; }
     break;
 
   case 37:
-#line 521 "grammar.y"
+#line 507 "grammar.y"
     { (yyval.integer) = (yyvsp[(1) - (2)].integer) | (yyvsp[(2) - (2)].integer); }
     break;
 
   case 38:
-#line 526 "grammar.y"
+#line 512 "grammar.y"
     { (yyval.integer) = STRING_GFLAGS_WIDE; }
     break;
 
   case 39:
-#line 527 "grammar.y"
+#line 513 "grammar.y"
     { (yyval.integer) = STRING_GFLAGS_ASCII; }
     break;
 
   case 40:
-#line 528 "grammar.y"
+#line 514 "grammar.y"
     { (yyval.integer) = STRING_GFLAGS_NO_CASE; }
     break;
 
   case 41:
-#line 529 "grammar.y"
+#line 515 "grammar.y"
     { (yyval.integer) = STRING_GFLAGS_FULL_WORD; }
     break;
 
   case 42:
-#line 535 "grammar.y"
+#line 521 "grammar.y"
     {
         int var_index = yr_parser_lookup_loop_variable(yyscanner, (yyvsp[(1) - (1)].c_string));
 
@@ -2181,9 +2167,7 @@ yyreduce:
           // externals variables reside.
 
           YR_OBJECT* object = (YR_OBJECT*) yr_hash_table_lookup(
-              compiler->objects_table,
-              (yyvsp[(1) - (1)].c_string),
-              NULL);
+              compiler->objects_table, (yyvsp[(1) - (1)].c_string), NULL);
 
           if (object == NULL)
           {
@@ -2191,9 +2175,7 @@ yyreduce:
             char* ns = compiler->current_namespace->name;
 
             object = (YR_OBJECT*) yr_hash_table_lookup(
-                compiler->objects_table,
-                (yyvsp[(1) - (1)].c_string),
-                ns);
+                compiler->objects_table, (yyvsp[(1) - (1)].c_string), ns);
           }
 
           if (object != NULL)
@@ -2201,9 +2183,7 @@ yyreduce:
             char* id;
 
             compiler->last_result = yr_arena_write_string(
-                compiler->sz_arena,
-                (yyvsp[(1) - (1)].c_string),
-                &id);
+                compiler->sz_arena, (yyvsp[(1) - (1)].c_string), &id);
 
             if (compiler->last_result == ERROR_SUCCESS)
               compiler->last_result = yr_parser_emit_with_arg_reloc(
@@ -2252,7 +2232,7 @@ yyreduce:
     break;
 
   case 43:
-#line 626 "grammar.y"
+#line 606 "grammar.y"
     {
         YR_OBJECT* field = NULL;
 
@@ -2266,9 +2246,7 @@ yyreduce:
             char* ident;
 
             compiler->last_result = yr_arena_write_string(
-              compiler->sz_arena,
-              (yyvsp[(3) - (3)].c_string),
-              &ident);
+              compiler->sz_arena, (yyvsp[(3) - (3)].c_string), &ident);
 
             if (compiler->last_result == ERROR_SUCCESS)
               compiler->last_result = yr_parser_emit_with_arg_reloc(
@@ -2291,8 +2269,7 @@ yyreduce:
         else
         {
           yr_compiler_set_error_extra_info(
-              compiler,
-              (yyvsp[(1) - (3)].expression).identifier);
+              compiler, (yyvsp[(1) - (3)].expression).identifier);
 
           compiler->last_result = ERROR_NOT_A_STRUCTURE;
         }
@@ -2304,7 +2281,7 @@ yyreduce:
     break;
 
   case 44:
-#line 675 "grammar.y"
+#line 652 "grammar.y"
     {
         if ((yyvsp[(1) - (4)].expression).type == EXPRESSION_TYPE_OBJECT &&
             (yyvsp[(1) - (4)].expression).value.object->type == OBJECT_TYPE_ARRAY)
@@ -2319,9 +2296,7 @@ yyreduce:
           ERROR_IF(compiler->last_result != ERROR_SUCCESS);
 
           compiler->last_result = yr_parser_emit(
-              yyscanner,
-              OP_INDEX_ARRAY,
-              NULL);
+              yyscanner, OP_INDEX_ARRAY, NULL);
 
           YR_OBJECT_ARRAY* array = (YR_OBJECT_ARRAY*) (yyvsp[(1) - (4)].expression).value.object;
 
@@ -2342,9 +2317,7 @@ yyreduce:
           ERROR_IF(compiler->last_result != ERROR_SUCCESS);
 
           compiler->last_result = yr_parser_emit(
-              yyscanner,
-              OP_LOOKUP_DICT,
-              NULL);
+              yyscanner, OP_LOOKUP_DICT, NULL);
 
           YR_OBJECT_DICTIONARY* dict = (YR_OBJECT_DICTIONARY*) (yyvsp[(1) - (4)].expression).value.object;
 
@@ -2355,8 +2328,7 @@ yyreduce:
         else
         {
           yr_compiler_set_error_extra_info(
-              compiler,
-              (yyvsp[(1) - (4)].expression).identifier);
+              compiler, (yyvsp[(1) - (4)].expression).identifier);
 
           compiler->last_result = ERROR_NOT_INDEXABLE;
         }
@@ -2366,7 +2338,7 @@ yyreduce:
     break;
 
   case 45:
-#line 735 "grammar.y"
+#line 707 "grammar.y"
     {
         char* args_fmt;
 
@@ -2378,9 +2350,7 @@ yyreduce:
 
           if (compiler->last_result == ERROR_SUCCESS)
             compiler->last_result = yr_arena_write_string(
-              compiler->sz_arena,
-              (yyvsp[(3) - (4)].c_string),
-              &args_fmt);
+              compiler->sz_arena, (yyvsp[(3) - (4)].c_string), &args_fmt);
 
           if (compiler->last_result == ERROR_SUCCESS)
             compiler->last_result = yr_parser_emit_with_arg_reloc(
@@ -2399,8 +2369,7 @@ yyreduce:
         else
         {
           yr_compiler_set_error_extra_info(
-              compiler,
-              (yyvsp[(1) - (4)].expression).identifier);
+              compiler, (yyvsp[(1) - (4)].expression).identifier);
 
           compiler->last_result = ERROR_NOT_A_FUNCTION;
         }
@@ -2412,17 +2381,17 @@ yyreduce:
     break;
 
   case 46:
-#line 781 "grammar.y"
+#line 750 "grammar.y"
     { (yyval.c_string) = yr_strdup(""); }
     break;
 
   case 47:
-#line 782 "grammar.y"
+#line 751 "grammar.y"
     { (yyval.c_string) = (yyvsp[(1) - (1)].c_string); }
     break;
 
   case 48:
-#line 787 "grammar.y"
+#line 756 "grammar.y"
     {
         (yyval.c_string) = (char*) yr_malloc(MAX_FUNCTION_ARGS + 1);
 
@@ -2450,7 +2419,7 @@ yyreduce:
     break;
 
   case 49:
-#line 812 "grammar.y"
+#line 781 "grammar.y"
     {
         if (strlen((yyvsp[(1) - (3)].c_string)) == MAX_FUNCTION_ARGS)
         {
@@ -2485,7 +2454,7 @@ yyreduce:
     break;
 
   case 50:
-#line 848 "grammar.y"
+#line 817 "grammar.y"
     {
         SIZED_STRING* sized_string = (yyvsp[(1) - (1)].sized_string);
         RE* re;
@@ -2530,14 +2499,12 @@ yyreduce:
     break;
 
   case 51:
-#line 894 "grammar.y"
+#line 863 "grammar.y"
     {
         if ((yyvsp[(1) - (1)].expression).type == EXPRESSION_TYPE_STRING)
         {
           compiler->last_result = yr_parser_emit(
-              yyscanner,
-              OP_STR_TO_BOOL,
-              NULL);
+              yyscanner, OP_STR_TO_BOOL, NULL);
 
           ERROR_IF(compiler->last_result != ERROR_SUCCESS);
         }
@@ -2547,7 +2514,7 @@ yyreduce:
     break;
 
   case 52:
-#line 911 "grammar.y"
+#line 878 "grammar.y"
     {
         compiler->last_result = yr_parser_emit_with_arg(
             yyscanner, OP_PUSH, 1, NULL, NULL);
@@ -2559,7 +2526,7 @@ yyreduce:
     break;
 
   case 53:
-#line 920 "grammar.y"
+#line 887 "grammar.y"
     {
         compiler->last_result = yr_parser_emit_with_arg(
             yyscanner, OP_PUSH, 0, NULL, NULL);
@@ -2571,7 +2538,7 @@ yyreduce:
     break;
 
   case 54:
-#line 929 "grammar.y"
+#line 896 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(1) - (3)].expression), EXPRESSION_TYPE_STRING, "matches");
         CHECK_TYPE((yyvsp[(3) - (3)].expression), EXPRESSION_TYPE_REGEXP, "matches");
@@ -2589,15 +2556,13 @@ yyreduce:
     break;
 
   case 55:
-#line 944 "grammar.y"
+#line 911 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(1) - (3)].expression), EXPRESSION_TYPE_STRING, "contains");
         CHECK_TYPE((yyvsp[(3) - (3)].expression), EXPRESSION_TYPE_STRING, "contains");
 
         compiler->last_result = yr_parser_emit(
-            yyscanner,
-            OP_CONTAINS,
-            NULL);
+            yyscanner, OP_CONTAINS, NULL);
 
         ERROR_IF(compiler->last_result != ERROR_SUCCESS);
 
@@ -2606,7 +2571,7 @@ yyreduce:
     break;
 
   case 56:
-#line 958 "grammar.y"
+#line 923 "grammar.y"
     {
         int result = yr_parser_reduce_string_identifier(
             yyscanner,
@@ -2623,15 +2588,12 @@ yyreduce:
     break;
 
   case 57:
-#line 972 "grammar.y"
+#line 937 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(3) - (3)].expression), EXPRESSION_TYPE_INTEGER, "at");
 
         compiler->last_result = yr_parser_reduce_string_identifier(
-            yyscanner,
-            (yyvsp[(1) - (3)].c_string),
-            OP_FOUND_AT,
-            (yyvsp[(3) - (3)].expression).value.integer);
+            yyscanner, (yyvsp[(1) - (3)].c_string), OP_FOUND_AT, (yyvsp[(3) - (3)].expression).value.integer);
 
         yr_free((yyvsp[(1) - (3)].c_string));
 
@@ -2642,13 +2604,10 @@ yyreduce:
     break;
 
   case 58:
-#line 988 "grammar.y"
+#line 950 "grammar.y"
     {
         compiler->last_result = yr_parser_reduce_string_identifier(
-            yyscanner,
-            (yyvsp[(1) - (3)].c_string),
-            OP_FOUND_IN,
-            UNDEFINED);
+            yyscanner, (yyvsp[(1) - (3)].c_string), OP_FOUND_IN, UNDEFINED);
 
         yr_free((yyvsp[(1) - (3)].c_string));
 
@@ -2659,7 +2618,7 @@ yyreduce:
     break;
 
   case 59:
-#line 1002 "grammar.y"
+#line 961 "grammar.y"
     {
         int var_index;
 
@@ -2670,14 +2629,12 @@ yyreduce:
         ERROR_IF(compiler->last_result != ERROR_SUCCESS);
 
         var_index = yr_parser_lookup_loop_variable(
-            yyscanner,
-            (yyvsp[(3) - (4)].c_string));
+            yyscanner, (yyvsp[(3) - (4)].c_string));
 
         if (var_index >= 0)
         {
           yr_compiler_set_error_extra_info(
-              compiler,
-              (yyvsp[(3) - (4)].c_string));
+              compiler, (yyvsp[(3) - (4)].c_string));
 
           compiler->last_result = \
               ERROR_DUPLICATED_LOOP_IDENTIFIER;
@@ -2687,18 +2644,14 @@ yyreduce:
 
         // Push end-of-list marker
         compiler->last_result = yr_parser_emit_with_arg(
-            yyscanner,
-            OP_PUSH,
-            UNDEFINED,
-            NULL,
-            NULL);
+            yyscanner, OP_PUSH, UNDEFINED, NULL, NULL);
 
         ERROR_IF(compiler->last_result != ERROR_SUCCESS);
       }
     break;
 
   case 60:
-#line 1038 "grammar.y"
+#line 991 "grammar.y"
     {
         int mem_offset = LOOP_LOCAL_VARS * compiler->loop_depth;
         uint8_t* addr;
@@ -2736,7 +2689,7 @@ yyreduce:
     break;
 
   case 61:
-#line 1073 "grammar.y"
+#line 1026 "grammar.y"
     {
         int mem_offset;
 
@@ -2820,7 +2773,7 @@ yyreduce:
     break;
 
   case 62:
-#line 1154 "grammar.y"
+#line 1107 "grammar.y"
     {
         int mem_offset = LOOP_LOCAL_VARS * compiler->loop_depth;
         uint8_t* addr;
@@ -2853,7 +2806,7 @@ yyreduce:
     break;
 
   case 63:
-#line 1184 "grammar.y"
+#line 1137 "grammar.y"
     {
         int mem_offset;
 
@@ -2906,7 +2859,7 @@ yyreduce:
     break;
 
   case 64:
-#line 1234 "grammar.y"
+#line 1187 "grammar.y"
     {
         yr_parser_emit(yyscanner, OP_OF, NULL);
 
@@ -2915,7 +2868,7 @@ yyreduce:
     break;
 
   case 65:
-#line 1240 "grammar.y"
+#line 1193 "grammar.y"
     {
         yr_parser_emit(yyscanner, OP_NOT, NULL);
 
@@ -2924,7 +2877,7 @@ yyreduce:
     break;
 
   case 66:
-#line 1246 "grammar.y"
+#line 1199 "grammar.y"
     {
         int64_t* jmp_destination_addr;
 
@@ -2952,7 +2905,7 @@ yyreduce:
     break;
 
   case 67:
-#line 1271 "grammar.y"
+#line 1224 "grammar.y"
     {
         uint8_t* and_addr;
 
@@ -2990,7 +2943,7 @@ yyreduce:
     break;
 
   case 68:
-#line 1306 "grammar.y"
+#line 1259 "grammar.y"
     {
         int64_t* jmp_destination_addr;
 
@@ -3017,7 +2970,7 @@ yyreduce:
     break;
 
   case 69:
-#line 1330 "grammar.y"
+#line 1283 "grammar.y"
     {
         uint8_t* or_addr;
 
@@ -3055,7 +3008,7 @@ yyreduce:
     break;
 
   case 70:
-#line 1365 "grammar.y"
+#line 1318 "grammar.y"
     {
         compiler->last_result = yr_parser_reduce_operation(
             yyscanner, "<", (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression));
@@ -3067,7 +3020,7 @@ yyreduce:
     break;
 
   case 71:
-#line 1374 "grammar.y"
+#line 1327 "grammar.y"
     {
         compiler->last_result = yr_parser_reduce_operation(
             yyscanner, ">", (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression));
@@ -3079,7 +3032,7 @@ yyreduce:
     break;
 
   case 72:
-#line 1383 "grammar.y"
+#line 1336 "grammar.y"
     {
         compiler->last_result = yr_parser_reduce_operation(
             yyscanner, "<=", (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression));
@@ -3091,7 +3044,7 @@ yyreduce:
     break;
 
   case 73:
-#line 1392 "grammar.y"
+#line 1345 "grammar.y"
     {
         compiler->last_result = yr_parser_reduce_operation(
             yyscanner, ">=", (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression));
@@ -3103,7 +3056,7 @@ yyreduce:
     break;
 
   case 74:
-#line 1401 "grammar.y"
+#line 1354 "grammar.y"
     {
         compiler->last_result = yr_parser_reduce_operation(
             yyscanner, "==", (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression));
@@ -3115,7 +3068,7 @@ yyreduce:
     break;
 
   case 75:
-#line 1410 "grammar.y"
+#line 1363 "grammar.y"
     {
         compiler->last_result = yr_parser_reduce_operation(
             yyscanner, "!=", (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression));
@@ -3127,31 +3080,31 @@ yyreduce:
     break;
 
   case 76:
-#line 1419 "grammar.y"
+#line 1372 "grammar.y"
     {
         (yyval.expression) = (yyvsp[(1) - (1)].expression);
       }
     break;
 
   case 77:
-#line 1423 "grammar.y"
+#line 1376 "grammar.y"
     {
         (yyval.expression) = (yyvsp[(2) - (3)].expression);
       }
     break;
 
   case 78:
-#line 1430 "grammar.y"
+#line 1383 "grammar.y"
     { (yyval.integer) = INTEGER_SET_ENUMERATION; }
     break;
 
   case 79:
-#line 1431 "grammar.y"
+#line 1384 "grammar.y"
     { (yyval.integer) = INTEGER_SET_RANGE; }
     break;
 
   case 80:
-#line 1437 "grammar.y"
+#line 1390 "grammar.y"
     {
         if ((yyvsp[(2) - (5)].expression).type != EXPRESSION_TYPE_INTEGER)
         {
@@ -3172,7 +3125,7 @@ yyreduce:
     break;
 
   case 81:
-#line 1459 "grammar.y"
+#line 1412 "grammar.y"
     {
         if ((yyvsp[(1) - (1)].expression).type != EXPRESSION_TYPE_INTEGER)
         {
@@ -3187,7 +3140,7 @@ yyreduce:
     break;
 
   case 82:
-#line 1471 "grammar.y"
+#line 1424 "grammar.y"
     {
         if ((yyvsp[(3) - (3)].expression).type != EXPRESSION_TYPE_INTEGER)
         {
@@ -3201,7 +3154,7 @@ yyreduce:
     break;
 
   case 83:
-#line 1486 "grammar.y"
+#line 1439 "grammar.y"
     {
         // Push end-of-list marker
         yr_parser_emit_with_arg(yyscanner, OP_PUSH, UNDEFINED, NULL, NULL);
@@ -3209,7 +3162,7 @@ yyreduce:
     break;
 
   case 85:
-#line 1492 "grammar.y"
+#line 1445 "grammar.y"
     {
         yr_parser_emit_with_arg(yyscanner, OP_PUSH, UNDEFINED, NULL, NULL);
         yr_parser_emit_pushes_for_strings(yyscanner, "$*");
@@ -3217,7 +3170,7 @@ yyreduce:
     break;
 
   case 88:
-#line 1507 "grammar.y"
+#line 1460 "grammar.y"
     {
         yr_parser_emit_pushes_for_strings(yyscanner, (yyvsp[(1) - (1)].c_string));
         yr_free((yyvsp[(1) - (1)].c_string));
@@ -3225,7 +3178,7 @@ yyreduce:
     break;
 
   case 89:
-#line 1512 "grammar.y"
+#line 1465 "grammar.y"
     {
         yr_parser_emit_pushes_for_strings(yyscanner, (yyvsp[(1) - (1)].c_string));
         yr_free((yyvsp[(1) - (1)].c_string));
@@ -3233,28 +3186,28 @@ yyreduce:
     break;
 
   case 91:
-#line 1522 "grammar.y"
+#line 1475 "grammar.y"
     {
         yr_parser_emit_with_arg(yyscanner, OP_PUSH, UNDEFINED, NULL, NULL);
       }
     break;
 
   case 92:
-#line 1526 "grammar.y"
+#line 1479 "grammar.y"
     {
         yr_parser_emit_with_arg(yyscanner, OP_PUSH, 1, NULL, NULL);
       }
     break;
 
   case 93:
-#line 1534 "grammar.y"
+#line 1487 "grammar.y"
     {
         (yyval.expression) = (yyvsp[(2) - (3)].expression);
       }
     break;
 
   case 94:
-#line 1538 "grammar.y"
+#line 1491 "grammar.y"
     {
         compiler->last_result = yr_parser_emit(
             yyscanner, OP_FILESIZE, NULL);
@@ -3267,7 +3220,7 @@ yyreduce:
     break;
 
   case 95:
-#line 1548 "grammar.y"
+#line 1501 "grammar.y"
     {
         yywarning(yyscanner,
             "Using deprecated \"entrypoint\" keyword. Use the \"entry_point\" "
@@ -3284,7 +3237,7 @@ yyreduce:
     break;
 
   case 96:
-#line 1562 "grammar.y"
+#line 1515 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(3) - (4)].expression), EXPRESSION_TYPE_INTEGER, "intXXXX or uintXXXX");
 
@@ -3303,7 +3256,7 @@ yyreduce:
     break;
 
   case 97:
-#line 1578 "grammar.y"
+#line 1531 "grammar.y"
     {
         compiler->last_result = yr_parser_emit_with_arg(
             yyscanner, OP_PUSH, (yyvsp[(1) - (1)].integer), NULL, NULL);
@@ -3316,7 +3269,7 @@ yyreduce:
     break;
 
   case 98:
-#line 1588 "grammar.y"
+#line 1541 "grammar.y"
     {
         compiler->last_result = yr_parser_emit_with_arg_double(
             yyscanner, OP_PUSH, (yyvsp[(1) - (1)].double_), NULL, NULL);
@@ -3328,7 +3281,7 @@ yyreduce:
     break;
 
   case 99:
-#line 1597 "grammar.y"
+#line 1550 "grammar.y"
     {
         SIZED_STRING* sized_string;
 
@@ -3355,13 +3308,10 @@ yyreduce:
     break;
 
   case 100:
-#line 1621 "grammar.y"
+#line 1574 "grammar.y"
     {
         compiler->last_result = yr_parser_reduce_string_identifier(
-            yyscanner,
-            (yyvsp[(1) - (1)].c_string),
-            OP_COUNT,
-            UNDEFINED);
+            yyscanner, (yyvsp[(1) - (1)].c_string), OP_COUNT, UNDEFINED);
 
         yr_free((yyvsp[(1) - (1)].c_string));
 
@@ -3373,13 +3323,10 @@ yyreduce:
     break;
 
   case 101:
-#line 1636 "grammar.y"
+#line 1586 "grammar.y"
     {
         compiler->last_result = yr_parser_reduce_string_identifier(
-            yyscanner,
-            (yyvsp[(1) - (4)].c_string),
-            OP_OFFSET,
-            UNDEFINED);
+            yyscanner, (yyvsp[(1) - (4)].c_string), OP_OFFSET, UNDEFINED);
 
         yr_free((yyvsp[(1) - (4)].c_string));
 
@@ -3391,21 +3338,14 @@ yyreduce:
     break;
 
   case 102:
-#line 1651 "grammar.y"
+#line 1598 "grammar.y"
     {
         compiler->last_result = yr_parser_emit_with_arg(
-            yyscanner,
-            OP_PUSH,
-            1,
-            NULL,
-            NULL);
+            yyscanner, OP_PUSH, 1, NULL, NULL);
 
         if (compiler->last_result == ERROR_SUCCESS)
           compiler->last_result = yr_parser_reduce_string_identifier(
-              yyscanner,
-              (yyvsp[(1) - (1)].c_string),
-              OP_OFFSET,
-              UNDEFINED);
+              yyscanner, (yyvsp[(1) - (1)].c_string), OP_OFFSET, UNDEFINED);
 
         yr_free((yyvsp[(1) - (1)].c_string));
 
@@ -3417,13 +3357,10 @@ yyreduce:
     break;
 
   case 103:
-#line 1674 "grammar.y"
+#line 1614 "grammar.y"
     {
         compiler->last_result = yr_parser_reduce_string_identifier(
-            yyscanner,
-            (yyvsp[(1) - (4)].c_string),
-            OP_LENGTH,
-            UNDEFINED);
+            yyscanner, (yyvsp[(1) - (4)].c_string), OP_LENGTH, UNDEFINED);
 
         yr_free((yyvsp[(1) - (4)].c_string));
 
@@ -3435,21 +3372,14 @@ yyreduce:
     break;
 
   case 104:
-#line 1689 "grammar.y"
+#line 1626 "grammar.y"
     {
         compiler->last_result = yr_parser_emit_with_arg(
-            yyscanner,
-            OP_PUSH,
-            1,
-            NULL,
-            NULL);
+            yyscanner, OP_PUSH, 1, NULL, NULL);
 
         if (compiler->last_result == ERROR_SUCCESS)
           compiler->last_result = yr_parser_reduce_string_identifier(
-              yyscanner,
-              (yyvsp[(1) - (1)].c_string),
-              OP_LENGTH,
-              UNDEFINED);
+              yyscanner, (yyvsp[(1) - (1)].c_string), OP_LENGTH, UNDEFINED);
 
         yr_free((yyvsp[(1) - (1)].c_string));
 
@@ -3461,7 +3391,7 @@ yyreduce:
     break;
 
   case 105:
-#line 1712 "grammar.y"
+#line 1642 "grammar.y"
     {
         if ((yyvsp[(1) - (1)].expression).type == EXPRESSION_TYPE_INTEGER)  // loop identifier
         {
@@ -3508,7 +3438,7 @@ yyreduce:
     break;
 
   case 106:
-#line 1756 "grammar.y"
+#line 1686 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(2) - (2)].expression), EXPRESSION_TYPE_INTEGER | EXPRESSION_TYPE_FLOAT, "-");
 
@@ -3530,7 +3460,7 @@ yyreduce:
     break;
 
   case 107:
-#line 1775 "grammar.y"
+#line 1705 "grammar.y"
     {
         compiler->last_result = yr_parser_reduce_operation(
             yyscanner, "+", (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression));
@@ -3551,7 +3481,7 @@ yyreduce:
     break;
 
   case 108:
-#line 1793 "grammar.y"
+#line 1723 "grammar.y"
     {
         compiler->last_result = yr_parser_reduce_operation(
             yyscanner, "-", (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression));
@@ -3572,7 +3502,7 @@ yyreduce:
     break;
 
   case 109:
-#line 1811 "grammar.y"
+#line 1741 "grammar.y"
     {
         compiler->last_result = yr_parser_reduce_operation(
             yyscanner, "*", (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression));
@@ -3593,7 +3523,7 @@ yyreduce:
     break;
 
   case 110:
-#line 1829 "grammar.y"
+#line 1759 "grammar.y"
     {
         compiler->last_result = yr_parser_reduce_operation(
             yyscanner, "\\", (yyvsp[(1) - (3)].expression), (yyvsp[(3) - (3)].expression));
@@ -3622,7 +3552,7 @@ yyreduce:
     break;
 
   case 111:
-#line 1855 "grammar.y"
+#line 1785 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(1) - (3)].expression), EXPRESSION_TYPE_INTEGER, "%");
         CHECK_TYPE((yyvsp[(3) - (3)].expression), EXPRESSION_TYPE_INTEGER, "%");
@@ -3643,7 +3573,7 @@ yyreduce:
     break;
 
   case 112:
-#line 1873 "grammar.y"
+#line 1803 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(1) - (3)].expression), EXPRESSION_TYPE_INTEGER, "^");
         CHECK_TYPE((yyvsp[(3) - (3)].expression), EXPRESSION_TYPE_INTEGER, "^");
@@ -3656,7 +3586,7 @@ yyreduce:
     break;
 
   case 113:
-#line 1883 "grammar.y"
+#line 1813 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(1) - (3)].expression), EXPRESSION_TYPE_INTEGER, "^");
         CHECK_TYPE((yyvsp[(3) - (3)].expression), EXPRESSION_TYPE_INTEGER, "^");
@@ -3669,7 +3599,7 @@ yyreduce:
     break;
 
   case 114:
-#line 1893 "grammar.y"
+#line 1823 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(1) - (3)].expression), EXPRESSION_TYPE_INTEGER, "|");
         CHECK_TYPE((yyvsp[(3) - (3)].expression), EXPRESSION_TYPE_INTEGER, "|");
@@ -3682,7 +3612,7 @@ yyreduce:
     break;
 
   case 115:
-#line 1903 "grammar.y"
+#line 1833 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(2) - (2)].expression), EXPRESSION_TYPE_INTEGER, "~");
 
@@ -3695,7 +3625,7 @@ yyreduce:
     break;
 
   case 116:
-#line 1913 "grammar.y"
+#line 1843 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(1) - (3)].expression), EXPRESSION_TYPE_INTEGER, "<<");
         CHECK_TYPE((yyvsp[(3) - (3)].expression), EXPRESSION_TYPE_INTEGER, "<<");
@@ -3708,7 +3638,7 @@ yyreduce:
     break;
 
   case 117:
-#line 1923 "grammar.y"
+#line 1853 "grammar.y"
     {
         CHECK_TYPE((yyvsp[(1) - (3)].expression), EXPRESSION_TYPE_INTEGER, ">>");
         CHECK_TYPE((yyvsp[(3) - (3)].expression), EXPRESSION_TYPE_INTEGER, ">>");
@@ -3721,7 +3651,7 @@ yyreduce:
     break;
 
   case 118:
-#line 1933 "grammar.y"
+#line 1863 "grammar.y"
     {
         (yyval.expression) = (yyvsp[(1) - (1)].expression);
       }
@@ -3729,7 +3659,7 @@ yyreduce:
 
 
 /* Line 1267 of yacc.c.  */
-#line 3733 "grammar.c"
+#line 3663 "grammar.c"
       default: break;
     }
   YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
@@ -3943,6 +3873,6 @@ yyreturn:
 }
 
 
-#line 1938 "grammar.y"
+#line 1868 "grammar.y"
 
 
diff --git a/libyara/grammar.y b/libyara/grammar.y
index 3033dbb..5f6d2f0 100644
--- a/libyara/grammar.y
+++ b/libyara/grammar.y
@@ -220,12 +220,7 @@ rule
     : rule_modifiers _RULE_ _IDENTIFIER_ tags '{' meta strings
       {
         YR_RULE* rule = yr_parser_reduce_rule_declaration_phase_1(
-            yyscanner,
-            $1,
-            $3,
-            $4,
-            $7,
-            $6);
+            yyscanner, (int32_t) $1, $3, $4, $7, $6);
 
         ERROR_IF(rule == NULL);
 
@@ -471,10 +466,7 @@ string_declaration
     : _STRING_IDENTIFIER_ '=' _TEXT_STRING_ string_modifiers
       {
         $$ = yr_parser_reduce_string_declaration(
-            yyscanner,
-            $4,
-            $1,
-            $3);
+            yyscanner, (int32_t) $4, $1, $3);
 
         yr_free($1);
         yr_free($3);
@@ -488,10 +480,7 @@ string_declaration
       _REGEXP_ string_modifiers
       {
         $$ = yr_parser_reduce_string_declaration(
-            yyscanner,
-            $5 | STRING_GFLAGS_REGEXP,
-            $1,
-            $4);
+            yyscanner, (int32_t) $5 | STRING_GFLAGS_REGEXP, $1, $4);
 
         yr_free($1);
         yr_free($4);
@@ -503,10 +492,7 @@ string_declaration
     | _STRING_IDENTIFIER_ '=' _HEX_STRING_
       {
         $$ = yr_parser_reduce_string_declaration(
-            yyscanner,
-            STRING_GFLAGS_HEXADECIMAL,
-            $1,
-            $3);
+            yyscanner, STRING_GFLAGS_HEXADECIMAL, $1, $3);
 
         yr_free($1);
         yr_free($3);
@@ -554,9 +540,7 @@ identifier
           // externals variables reside.
 
           YR_OBJECT* object = (YR_OBJECT*) yr_hash_table_lookup(
-              compiler->objects_table,
-              $1,
-              NULL);
+              compiler->objects_table, $1, NULL);
 
           if (object == NULL)
           {
@@ -564,9 +548,7 @@ identifier
             char* ns = compiler->current_namespace->name;
 
             object = (YR_OBJECT*) yr_hash_table_lookup(
-                compiler->objects_table,
-                $1,
-                ns);
+                compiler->objects_table, $1, ns);
           }
 
           if (object != NULL)
@@ -574,9 +556,7 @@ identifier
             char* id;
 
             compiler->last_result = yr_arena_write_string(
-                compiler->sz_arena,
-                $1,
-                &id);
+                compiler->sz_arena, $1, &id);
 
             if (compiler->last_result == ERROR_SUCCESS)
               compiler->last_result = yr_parser_emit_with_arg_reloc(
@@ -636,9 +616,7 @@ identifier
             char* ident;
 
             compiler->last_result = yr_arena_write_string(
-              compiler->sz_arena,
-              $3,
-              &ident);
+              compiler->sz_arena, $3, &ident);
 
             if (compiler->last_result == ERROR_SUCCESS)
               compiler->last_result = yr_parser_emit_with_arg_reloc(
@@ -661,8 +639,7 @@ identifier
         else
         {
           yr_compiler_set_error_extra_info(
-              compiler,
-              $1.identifier);
+              compiler, $1.identifier);
 
           compiler->last_result = ERROR_NOT_A_STRUCTURE;
         }
@@ -686,9 +663,7 @@ identifier
           ERROR_IF(compiler->last_result != ERROR_SUCCESS);
 
           compiler->last_result = yr_parser_emit(
-              yyscanner,
-              OP_INDEX_ARRAY,
-              NULL);
+              yyscanner, OP_INDEX_ARRAY, NULL);
 
           YR_OBJECT_ARRAY* array = (YR_OBJECT_ARRAY*) $1.value.object;
 
@@ -709,9 +684,7 @@ identifier
           ERROR_IF(compiler->last_result != ERROR_SUCCESS);
 
           compiler->last_result = yr_parser_emit(
-              yyscanner,
-              OP_LOOKUP_DICT,
-              NULL);
+              yyscanner, OP_LOOKUP_DICT, NULL);
 
           YR_OBJECT_DICTIONARY* dict = (YR_OBJECT_DICTIONARY*) $1.value.object;
 
@@ -722,8 +695,7 @@ identifier
         else
         {
           yr_compiler_set_error_extra_info(
-              compiler,
-              $1.identifier);
+              compiler, $1.identifier);
 
           compiler->last_result = ERROR_NOT_INDEXABLE;
         }
@@ -743,9 +715,7 @@ identifier
 
           if (compiler->last_result == ERROR_SUCCESS)
             compiler->last_result = yr_arena_write_string(
-              compiler->sz_arena,
-              $3,
-              &args_fmt);
+              compiler->sz_arena, $3, &args_fmt);
 
           if (compiler->last_result == ERROR_SUCCESS)
             compiler->last_result = yr_parser_emit_with_arg_reloc(
@@ -764,8 +734,7 @@ identifier
         else
         {
           yr_compiler_set_error_extra_info(
-              compiler,
-              $1.identifier);
+              compiler, $1.identifier);
 
           compiler->last_result = ERROR_NOT_A_FUNCTION;
         }
@@ -895,9 +864,7 @@ boolean_expression
         if ($1.type == EXPRESSION_TYPE_STRING)
         {
           compiler->last_result = yr_parser_emit(
-              yyscanner,
-              OP_STR_TO_BOOL,
-              NULL);
+              yyscanner, OP_STR_TO_BOOL, NULL);
 
           ERROR_IF(compiler->last_result != ERROR_SUCCESS);
         }
@@ -946,9 +913,7 @@ expression
         CHECK_TYPE($3, EXPRESSION_TYPE_STRING, "contains");
 
         compiler->last_result = yr_parser_emit(
-            yyscanner,
-            OP_CONTAINS,
-            NULL);
+            yyscanner, OP_CONTAINS, NULL);
 
         ERROR_IF(compiler->last_result != ERROR_SUCCESS);
 
@@ -973,10 +938,7 @@ expression
         CHECK_TYPE($3, EXPRESSION_TYPE_INTEGER, "at");
 
         compiler->last_result = yr_parser_reduce_string_identifier(
-            yyscanner,
-            $1,
-            OP_FOUND_AT,
-            $3.value.integer);
+            yyscanner, $1, OP_FOUND_AT, $3.value.integer);
 
         yr_free($1);
 
@@ -987,10 +949,7 @@ expression
     | _STRING_IDENTIFIER_ _IN_ range
       {
         compiler->last_result = yr_parser_reduce_string_identifier(
-            yyscanner,
-            $1,
-            OP_FOUND_IN,
-            UNDEFINED);
+            yyscanner, $1, OP_FOUND_IN, UNDEFINED);
 
         yr_free($1);
 
@@ -1009,14 +968,12 @@ expression
         ERROR_IF(compiler->last_result != ERROR_SUCCESS);
 
         var_index = yr_parser_lookup_loop_variable(
-            yyscanner,
-            $3);
+            yyscanner, $3);
 
         if (var_index >= 0)
         {
           yr_compiler_set_error_extra_info(
-              compiler,
-              $3);
+              compiler, $3);
 
           compiler->last_result = \
               ERROR_DUPLICATED_LOOP_IDENTIFIER;
@@ -1026,11 +983,7 @@ expression
 
         // Push end-of-list marker
         compiler->last_result = yr_parser_emit_with_arg(
-            yyscanner,
-            OP_PUSH,
-            UNDEFINED,
-            NULL,
-            NULL);
+            yyscanner, OP_PUSH, UNDEFINED, NULL, NULL);
 
         ERROR_IF(compiler->last_result != ERROR_SUCCESS);
       }
@@ -1620,10 +1573,7 @@ primary_expression
     | _STRING_COUNT_
       {
         compiler->last_result = yr_parser_reduce_string_identifier(
-            yyscanner,
-            $1,
-            OP_COUNT,
-            UNDEFINED);
+            yyscanner, $1, OP_COUNT, UNDEFINED);
 
         yr_free($1);
 
@@ -1635,10 +1585,7 @@ primary_expression
     | _STRING_OFFSET_ '[' primary_expression ']'
       {
         compiler->last_result = yr_parser_reduce_string_identifier(
-            yyscanner,
-            $1,
-            OP_OFFSET,
-            UNDEFINED);
+            yyscanner, $1, OP_OFFSET, UNDEFINED);
 
         yr_free($1);
 
@@ -1650,18 +1597,11 @@ primary_expression
     | _STRING_OFFSET_
       {
         compiler->last_result = yr_parser_emit_with_arg(
-            yyscanner,
-            OP_PUSH,
-            1,
-            NULL,
-            NULL);
+            yyscanner, OP_PUSH, 1, NULL, NULL);
 
         if (compiler->last_result == ERROR_SUCCESS)
           compiler->last_result = yr_parser_reduce_string_identifier(
-              yyscanner,
-              $1,
-              OP_OFFSET,
-              UNDEFINED);
+              yyscanner, $1, OP_OFFSET, UNDEFINED);
 
         yr_free($1);
 
@@ -1673,10 +1613,7 @@ primary_expression
     | _STRING_LENGTH_ '[' primary_expression ']'
       {
         compiler->last_result = yr_parser_reduce_string_identifier(
-            yyscanner,
-            $1,
-            OP_LENGTH,
-            UNDEFINED);
+            yyscanner, $1, OP_LENGTH, UNDEFINED);
 
         yr_free($1);
 
@@ -1688,18 +1625,11 @@ primary_expression
     | _STRING_LENGTH_
       {
         compiler->last_result = yr_parser_emit_with_arg(
-            yyscanner,
-            OP_PUSH,
-            1,
-            NULL,
-            NULL);
+            yyscanner, OP_PUSH, 1, NULL, NULL);
 
         if (compiler->last_result == ERROR_SUCCESS)
           compiler->last_result = yr_parser_reduce_string_identifier(
-              yyscanner,
-              $1,
-              OP_LENGTH,
-              UNDEFINED);
+              yyscanner, $1, OP_LENGTH, UNDEFINED);
 
         yr_free($1);
 
diff --git a/libyara/hash.c b/libyara/hash.c
index f63a65d..fed3875 100644
--- a/libyara/hash.c
+++ b/libyara/hash.c
@@ -70,9 +70,9 @@ uint32_t byte_to_int32[]  =
 uint32_t hash(
     uint32_t seed,
     uint8_t* buffer,
-    int len)
+    size_t len)
 {
-  int i;
+  size_t i;
   uint32_t result = seed;
 
   for (i = len - 1; i > 0; i--)
diff --git a/libyara/hex_grammar.c b/libyara/hex_grammar.c
index 4a4de07..d013c95 100644
--- a/libyara/hex_grammar.c
+++ b/libyara/hex_grammar.c
@@ -147,7 +147,7 @@
 typedef union YYSTYPE
 #line 64 "hex_grammar.y"
 {
-  int integer;
+  int64_t integer;
   RE_NODE *re_node;
 }
 /* Line 193 of yacc.c.  */
@@ -1601,8 +1601,8 @@ yyreduce:
 
         ERROR_IF((yyval.re_node) == NULL, ERROR_INSUFICIENT_MEMORY);
 
-        (yyval.re_node)->start = (yyvsp[(2) - (3)].integer);
-        (yyval.re_node)->end = (yyvsp[(2) - (3)].integer);
+        (yyval.re_node)->start = (int) (yyvsp[(2) - (3)].integer);
+        (yyval.re_node)->end = (int) (yyvsp[(2) - (3)].integer);
       }
     break;
 
@@ -1642,8 +1642,8 @@ yyreduce:
 
         ERROR_IF((yyval.re_node) == NULL, ERROR_INSUFICIENT_MEMORY);
 
-        (yyval.re_node)->start = (yyvsp[(2) - (5)].integer);
-        (yyval.re_node)->end = (yyvsp[(4) - (5)].integer);
+        (yyval.re_node)->start = (int) (yyvsp[(2) - (5)].integer);
+        (yyval.re_node)->end = (int) (yyvsp[(4) - (5)].integer);
       }
     break;
 
@@ -1673,7 +1673,7 @@ yyreduce:
 
         ERROR_IF((yyval.re_node) == NULL, ERROR_INSUFICIENT_MEMORY);
 
-        (yyval.re_node)->start = (yyvsp[(2) - (4)].integer);
+        (yyval.re_node)->start = (int) (yyvsp[(2) - (4)].integer);
         (yyval.re_node)->end = INT_MAX;
       }
     break;
@@ -1731,7 +1731,7 @@ yyreduce:
 
         ERROR_IF((yyval.re_node) == NULL, ERROR_INSUFICIENT_MEMORY);
 
-        (yyval.re_node)->value = (yyvsp[(1) - (1)].integer);
+        (yyval.re_node)->value = (int) (yyvsp[(1) - (1)].integer);
       }
     break;
 
diff --git a/libyara/hex_grammar.h b/libyara/hex_grammar.h
index f59c007..2186968 100644
--- a/libyara/hex_grammar.h
+++ b/libyara/hex_grammar.h
@@ -56,7 +56,7 @@
 typedef union YYSTYPE
 #line 64 "hex_grammar.y"
 {
-  int integer;
+  int64_t integer;
   RE_NODE *re_node;
 }
 /* Line 1529 of yacc.c.  */
diff --git a/libyara/hex_grammar.y b/libyara/hex_grammar.y
index f803e00..adcfa45 100644
--- a/libyara/hex_grammar.y
+++ b/libyara/hex_grammar.y
@@ -62,7 +62,7 @@ limitations under the License.
 %lex-param {HEX_LEX_ENVIRONMENT *lex_env}
 
 %union {
-  int integer;
+  int64_t integer;
   RE_NODE *re_node;
 }
 
@@ -253,8 +253,8 @@ range
 
         ERROR_IF($$ == NULL, ERROR_INSUFICIENT_MEMORY);
 
-        $$->start = $2;
-        $$->end = $2;
+        $$->start = (int) $2;
+        $$->end = (int) $2;
       }
     | '[' _NUMBER_ '-' _NUMBER_ ']'
       {
@@ -291,8 +291,8 @@ range
 
         ERROR_IF($$ == NULL, ERROR_INSUFICIENT_MEMORY);
 
-        $$->start = $2;
-        $$->end = $4;
+        $$->start = (int) $2;
+        $$->end = (int) $4;
       }
     | '[' _NUMBER_ '-' ']'
       {
@@ -319,7 +319,7 @@ range
 
         ERROR_IF($$ == NULL, ERROR_INSUFICIENT_MEMORY);
 
-        $$->start = $2;
+        $$->start = (int) $2;
         $$->end = INT_MAX;
       }
     | '[' '-' ']'
@@ -372,7 +372,7 @@ byte
 
         ERROR_IF($$ == NULL, ERROR_INSUFICIENT_MEMORY);
 
-        $$->value = $1;
+        $$->value = (int) $1;
       }
     | _MASKED_BYTE_
       {
diff --git a/libyara/include/yara/arena.h b/libyara/include/yara/arena.h
index 5f11073..ddb5f0f 100644
--- a/libyara/include/yara/arena.h
+++ b/libyara/include/yara/arena.h
@@ -24,14 +24,14 @@ limitations under the License.
 
 #define ARENA_FLAGS_FIXED_SIZE   1
 #define ARENA_FLAGS_COALESCED    2
-#define ARENA_FILE_VERSION       9
+#define ARENA_FILE_VERSION       10
 
 #define EOL ((size_t) -1)
 
 
 typedef struct _YR_RELOC
 {
-  int32_t offset;
+  size_t offset;
   struct _YR_RELOC* next;
 
 } YR_RELOC;
@@ -82,7 +82,7 @@ void* yr_arena_base_address(
 void* yr_arena_next_address(
     YR_ARENA* arena,
     void* address,
-    int offset);
+    size_t offset);
 
 
 int yr_arena_coalesce(
diff --git a/libyara/include/yara/parser.h b/libyara/include/yara/parser.h
index 05be1af..584e1c0 100644
--- a/libyara/include/yara/parser.h
+++ b/libyara/include/yara/parser.h
@@ -83,7 +83,7 @@ int yr_parser_reduce_rule_declaration_phase_2(
 
 YR_STRING* yr_parser_reduce_string_declaration(
     yyscan_t yyscanner,
-    int flags,
+    int32_t flags,
     const char* identifier,
     SIZED_STRING* str);
 
@@ -93,7 +93,7 @@ YR_META* yr_parser_reduce_meta_declaration(
     int32_t type,
     const char* identifier,
     const char* string,
-    int32_t integer);
+    int64_t integer);
 
 
 int yr_parser_reduce_string_identifier(
diff --git a/libyara/include/yara/sizedstr.h b/libyara/include/yara/sizedstr.h
index df832e5..c6e8732 100644
--- a/libyara/include/yara/sizedstr.h
+++ b/libyara/include/yara/sizedstr.h
@@ -17,6 +17,8 @@ limitations under the License.
 #ifndef _SIZEDSTR_H
 #define _SIZEDSTR_H
 
+#include <stddef.h>
+
 //
 // This struct is used to support strings containing null chars. The length of
 // the string is stored along the string data. However the string data is also
@@ -28,7 +30,7 @@ limitations under the License.
 
 typedef struct _SIZED_STRING
 {
-  int length;
+  size_t length;
   int flags;
   char c_string[1];
 
diff --git a/libyara/include/yara/types.h b/libyara/include/yara/types.h
index 66708dd..6ff4026 100644
--- a/libyara/include/yara/types.h
+++ b/libyara/include/yara/types.h
@@ -64,7 +64,7 @@ typedef struct _YR_NAMESPACE
 typedef struct _YR_META
 {
   int32_t type;
-  int32_t integer;
+  int64_t integer;
 
   DECLARE_REFERENCE(const char*, identifier);
   DECLARE_REFERENCE(char*, string);
diff --git a/libyara/object.c b/libyara/object.c
index 5fc9547..6bef40a 100644
--- a/libyara/object.c
+++ b/libyara/object.c
@@ -470,7 +470,7 @@ YR_OBJECT* _yr_object_lookup(
       }
       else if (*p >= '0' && *p <= '9')
       {
-        index = strtol(p, (char**) &p, 10);
+        index = (int) strtol(p, (char**) &p, 10);
       }
       else if (*p == '"')
       {
diff --git a/libyara/parser.c b/libyara/parser.c
index 889a145..dc4ebe4 100644
--- a/libyara/parser.c
+++ b/libyara/parser.c
@@ -351,7 +351,7 @@ int _yr_parser_write_string(
 
   if (flags & STRING_GFLAGS_LITERAL)
   {
-    (*string)->length = literal_string->length;
+    (*string)->length = (uint32_t) literal_string->length;
 
     result = yr_arena_write_data(
         compiler->sz_arena,
@@ -363,7 +363,7 @@ int _yr_parser_write_string(
     {
       result = yr_atoms_extract_from_string(
           (uint8_t*) literal_string->c_string,
-          literal_string->length,
+          (int32_t) literal_string->length,
           flags,
           &atom_list);
     }
@@ -909,7 +909,7 @@ YR_META* yr_parser_reduce_meta_declaration(
     int32_t type,
     const char* identifier,
     const char* string,
-    int32_t integer)
+    int64_t integer)
 {
   YR_COMPILER* compiler = yyget_extra(yyscanner);
   YR_META* meta;
diff --git a/libyara/re.c b/libyara/re.c
index 2bac25f..ff9b1e3 100644
--- a/libyara/re.c
+++ b/libyara/re.c
@@ -1615,7 +1615,7 @@ int yr_re_exec(
     input_incr = -input_incr;
   }
 
-  max_count = yr_min(input_size, RE_SCAN_LIMIT);
+  max_count = (int) yr_min(input_size, RE_SCAN_LIMIT);
 
   // Round down max_count to a multiple of character_size, this way if
   // character_size is 2 and input_size is impair we are ignoring the
diff --git a/libyara/scan.c b/libyara/scan.c
index 39336cf..63419cc 100644
--- a/libyara/scan.c
+++ b/libyara/scan.c
@@ -45,9 +45,9 @@ typedef struct _CALLBACK_ARGS
 
 int _yr_scan_compare(
     uint8_t* data,
-    int data_size,
+    size_t data_size,
     uint8_t* string,
-    int string_length)
+    size_t string_length)
 {
   uint8_t* s1 = data;
   uint8_t* s2 = string;
@@ -65,9 +65,9 @@ int _yr_scan_compare(
 
 int _yr_scan_icompare(
     uint8_t* data,
-    int data_size,
+    size_t data_size,
     uint8_t* string,
-    int string_length)
+    size_t string_length)
 {
   uint8_t* s1 = data;
   uint8_t* s2 = string;
@@ -85,9 +85,9 @@ int _yr_scan_icompare(
 
 int _yr_scan_wcompare(
     uint8_t* data,
-    int data_size,
+    size_t data_size,
     uint8_t* string,
-    int string_length)
+    size_t string_length)
 {
   uint8_t* s1 = data;
   uint8_t* s2 = string;
@@ -109,9 +109,9 @@ int _yr_scan_wcompare(
 
 int _yr_scan_wicompare(
     uint8_t* data,
-    int data_size,
+    size_t data_size,
     uint8_t* string,
-    int string_length)
+    size_t string_length)
 {
   uint8_t* s1 = data;
   uint8_t* s2 = string;
@@ -560,7 +560,9 @@ int _yr_scan_verify_chained_string_match(
           _yr_scan_remove_match_from_list(
               match, &string->unconfirmed_matches[tidx]);
 
-          match->length = match_offset - match->offset + match_length;
+          match->length = (int32_t) \
+              (match_offset - match->offset + match_length);
+
           match->data = match_data - match_offset + match->offset;
           match->prev = NULL;
           match->next = NULL;
diff --git a/libyara/sizedstr.c b/libyara/sizedstr.c
index c653669..a9e4519 100644
--- a/libyara/sizedstr.c
+++ b/libyara/sizedstr.c
@@ -21,7 +21,7 @@ int sized_string_cmp(
   SIZED_STRING* s1,
   SIZED_STRING* s2)
 {
-  int i = 0;
+  size_t i = 0;
 
   while (s1->length > i &&
          s2->length > i &&
diff --git a/libyara/strutils.c b/libyara/strutils.c
index 6e5e4e5..0684c53 100644
--- a/libyara/strutils.c
+++ b/libyara/strutils.c
@@ -24,10 +24,10 @@ limitations under the License.
 uint64_t xtoi(
     const char* hexstr)
 {
-  int l = strlen(hexstr);
+  size_t l = strlen(hexstr);
   uint64_t r = 0;
 
-  for (int i = 0; i < l; i++)
+  for (size_t i = 0; i < l; i++)
   {
     switch (hexstr[i])
     {
diff --git a/yara.c b/yara.c
index 898e5ce..a2a7cb6 100644
--- a/yara.c
+++ b/yara.c
@@ -550,7 +550,7 @@ int handle_message(int message, YR_RULE* rule, void* data)
           printf(",");
 
         if (meta->type == META_TYPE_INTEGER)
-          printf("%s=%d", meta->identifier, meta->integer);
+          printf("%s=%" PRId64, meta->identifier, meta->integer);
         else if (meta->type == META_TYPE_BOOLEAN)
           printf("%s=%s", meta->identifier, meta->integer ? "true" : "false");
         else

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/forensics/yara.git



More information about the forensics-changes mailing list