VirusTotal / yara-python

The Python interface for YARA
http://virustotal.github.io/yara/
Apache License 2.0
648 stars 179 forks source link

yara-python compilation warnings #117

Closed xambroz closed 2 years ago

xambroz commented 4 years ago

Hello, when compiling the yara-python 3.11.0 there are these compilation warnings:

gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switch
es -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-pro
tector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fPIC -DUSE_LINUX_P
ROC=1 -DHAVE_MEMMEM=1 -Iyara/libyara/include -Iyara/libyara/ -I. -I/usr/include/python3.7m -c yara-python.c -o build/temp.linux-x86_64-3.7/yara-python.o
yara-python.c: In function ‘convert_object_to_python’:                                                                 
yara-python.c:426:27: warning: comparison of integer expressions of different signedness: ‘int64_t’ {aka ‘long int’} and ‘long long unsigned int’ [-Wsign-compare]
  426 |       if (object->value.i != UNDEFINED)                                                                                                                                                                                               
      |                           ^~                                                                                                                                                                                                          
yara-python.c: In function ‘process_compile_externals’:                                                                                                                                                                                       
yara-python.c:976:16: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]                                                                                                                        
  976 |     identifier = PY_STRING_TO_C(key);                                                                          
      |                ^                                                                                               
yara-python.c:50:27: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]                                                                                                                     
   50 | #define PY_STRING_TO_C(x) PyUnicode_AsUTF8(x)                                                                  
      |                           ^~~~~~~~~~~~~~~~                                                                                                                                                                                            
yara-python.c:1005:19: note: in expansion of macro ‘PY_STRING_TO_C’                                                                                                                                                                           
 1005 |       char* str = PY_STRING_TO_C(value);           
      |                   ^~~~~~~~~~~~~~                                                                                                                                                                                                      
yara-python.c: In function ‘process_match_externals’:                                                                  
yara-python.c:1046:16: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] 
 1046 |     identifier = PY_STRING_TO_C(key);                                                                          
      |                ^                                                                                               
yara-python.c:50:27: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
   50 | #define PY_STRING_TO_C(x) PyUnicode_AsUTF8(x)                                                                                                                                                                                         
      |                           ^~~~~~~~~~~~~~~~         
yara-python.c:1075:19: note: in expansion of macro ‘PY_STRING_TO_C’                                                                                                                                                                           
 1075 |       char* str = PY_STRING_TO_C(value);                                                                       
      |                   ^~~~~~~~~~~~~~                                                                                                                                                                                                      
yara-python.c: In function ‘yara_compile’:                                                                                                                                                                                                    
yara-python.c:2054:18: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] 
 2054 |           source = PY_STRING_TO_C(value);
      |                  ^                                 
yara-python.c:2055:14: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] 
 2055 |           ns = PY_STRING_TO_C(key);
      |              ^                                     
yara-python.c:2087:20: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] 
 2087 |           filepath = PY_STRING_TO_C(value);
      |                    ^                               
yara-python.c:2088:14: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] 
 2088 |           ns = PY_STRING_TO_C(key);
      |              ^                                     

Especially the yara-python.c:426:27 might be causing some issues especially on other HW platforms than x86 where the yara is best tested.

Best regards Michal Ambroz