lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject [05/14] lucy-clownfish git commit: Address int warnings in CFC.
Date Sun, 20 Mar 2016 05:53:59 GMT
Address int warnings in CFC.

Quiet warnings exposed by adding `-Wconversion`.


Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/91f00051
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/91f00051
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/91f00051

Branch: refs/heads/master
Commit: 91f00051d7b434136244a7f44f3f6d1fe187464f
Parents: 338ab9f
Author: Marvin Humphrey <marvin@rectangular.com>
Authored: Fri Mar 18 23:41:26 2016 +0000
Committer: Marvin Humphrey <marvin@rectangular.com>
Committed: Sat Mar 19 22:19:41 2016 -0700

----------------------------------------------------------------------
 compiler/c/cfc.c                  |  5 +++--
 compiler/src/CFCBase.h            |  2 +-
 compiler/src/CFCCHtml.c           |  9 +++++----
 compiler/src/CFCClass.c           |  2 +-
 compiler/src/CFCDocuComment.c     |  6 +++---
 compiler/src/CFCFile.c            |  2 +-
 compiler/src/CFCGoFunc.c          | 12 ++++++------
 compiler/src/CFCGoTypeMap.c       |  8 ++++----
 compiler/src/CFCParcel.c          |  8 ++++----
 compiler/src/CFCParser.c          |  2 +-
 compiler/src/CFCPerl.c            |  2 +-
 compiler/src/CFCPerlConstructor.c |  2 +-
 compiler/src/CFCPerlMethod.c      |  2 +-
 compiler/src/CFCPerlPod.c         |  6 +++---
 compiler/src/CFCPerlSub.c         |  4 ++--
 compiler/src/CFCPyClass.c         |  2 +-
 compiler/src/CFCPyMethod.c        | 30 +++++++++++++++---------------
 compiler/src/CFCPython.c          |  4 ++--
 compiler/src/CFCRuby.c            |  2 +-
 compiler/src/CFCType.c            |  4 ++--
 compiler/src/CFCUtil.c            | 25 +++++++++++++------------
 compiler/src/CFCVersion.c         |  3 ++-
 22 files changed, 73 insertions(+), 69 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/91f00051/compiler/c/cfc.c
----------------------------------------------------------------------
diff --git a/compiler/c/cfc.c b/compiler/c/cfc.c
index 6f5f527..369a0b1 100644
--- a/compiler/c/cfc.c
+++ b/compiler/c/cfc.c
@@ -75,6 +75,7 @@ S_parse_string_array_argument(const char *arg, const char *name,
     size_t   arg_len  = strlen(arg);
     size_t   name_len = strlen(name);
     int      new_num_results;
+    size_t   amount;
     char   **new_results;
 
     if (arg_len < name_len
@@ -85,8 +86,8 @@ S_parse_string_array_argument(const char *arg, const char *name,
     }
 
     new_num_results = *num_results + 1;
-    new_results     = (char **)REALLOCATE(*results,
-                              (new_num_results + 1) * sizeof(char *));
+    amount = (((size_t)new_num_results + 1) * sizeof(char *));
+    new_results = (char **)REALLOCATE(*results, amount);
     new_results[new_num_results-1] = CFCUtil_strdup(arg + name_len + 1);
     new_results[new_num_results]   = NULL;
     *num_results = new_num_results;

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/91f00051/compiler/src/CFCBase.h
----------------------------------------------------------------------
diff --git a/compiler/src/CFCBase.h b/compiler/src/CFCBase.h
index 9117ae2..09ee662 100644
--- a/compiler/src/CFCBase.h
+++ b/compiler/src/CFCBase.h
@@ -33,7 +33,7 @@ typedef void (*CFCBase_destroy_t)(CFCBase *self);
 #ifdef CFC_NEED_BASE_STRUCT_DEF
 struct CFCBase {
     const CFCMeta *meta;
-    int refcount;
+    unsigned refcount;
 };
 #endif
 struct CFCMeta {

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/91f00051/compiler/src/CFCCHtml.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCCHtml.c b/compiler/src/CFCCHtml.c
index 6f42ea6..a054cb8 100644
--- a/compiler/src/CFCCHtml.c
+++ b/compiler/src/CFCCHtml.c
@@ -16,6 +16,7 @@
 
 #include <ctype.h>
 #include <stdlib.h>
+#include <stddef.h>
 #include <string.h>
 
 #include <cmark.h>
@@ -1091,8 +1092,8 @@ S_type_to_html(CFCType *type, const char *sep, CFCClass *doc_class)
{
             CFCUtil_die("Unprefixed object specifier '%s'", specifier);
         }
 
-        size_t      offset     = underscore + 1 - specifier;
-        char       *prefix     = CFCUtil_strndup(specifier, offset);
+        ptrdiff_t   offset     = underscore + 1 - specifier;
+        char       *prefix     = CFCUtil_strndup(specifier, (size_t)offset);
         const char *struct_sym = specifier + offset;
 
         if (!klass) {
@@ -1117,7 +1118,7 @@ S_type_to_html(CFCType *type, const char *sep, CFCClass *doc_class)
{
     const char *const_str = CFCType_const(type) ? "const " : "";
 
     int indirection = CFCType_get_indirection(type);
-    size_t asterisk_offset = indirection < 10 ? 10 - indirection : 0;
+    ptrdiff_t asterisk_offset = indirection < 10 ? 10 - indirection : 0;
     const char *asterisks = "**********";
     const char *ind_str   = asterisks + asterisk_offset;
 
@@ -1203,7 +1204,7 @@ S_relative_url(const char *url, CFCClass *base, int dir_level) {
     }
 
     // Create path back to root
-    size_t bytes = dir_level * 3;
+    size_t bytes = (size_t)(dir_level * 3);
     char *prefix = (char*)MALLOCATE(bytes + 1);
     for (size_t i = 0; i < bytes; i += 3) {
         memcpy(prefix + i, "../", 3);

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/91f00051/compiler/src/CFCClass.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCClass.c b/compiler/src/CFCClass.c
index 56edce5..77e0158 100644
--- a/compiler/src/CFCClass.c
+++ b/compiler/src/CFCClass.c
@@ -274,7 +274,7 @@ CFCClass_do_create(CFCClass *self, struct CFCParcel *parcel,
     char *short_class_var = (char*)MALLOCATE(struct_sym_len + 1);
     size_t i;
     for (i = 0; i < struct_sym_len; i++) {
-        short_class_var[i] = toupper(struct_sym[i]);
+        short_class_var[i] = (char)toupper(struct_sym[i]);
     }
     short_class_var[struct_sym_len] = '\0';
     self->short_class_var = short_class_var;

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/91f00051/compiler/src/CFCDocuComment.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCDocuComment.c b/compiler/src/CFCDocuComment.c
index f5c45cc..2bcc495 100644
--- a/compiler/src/CFCDocuComment.c
+++ b/compiler/src/CFCDocuComment.c
@@ -107,7 +107,7 @@ CFCDocuComment_parse(const char *raw_text) {
             && ((ptr == limit - 1) || isspace(*(ptr + 1)))
            ) {
             ptr++;
-            size_t brief_len = ptr - text;
+            size_t brief_len = (size_t)(ptr - text);
             self->brief = CFCUtil_strdup(text);
             self->brief[brief_len] = '\0';
             break;
@@ -136,7 +136,7 @@ CFCDocuComment_parse(const char *raw_text) {
         while (isspace(*ptr) && ptr < text_limit) { ptr++; }
         char *param_name = ptr;
         while ((isalnum(*ptr) || *ptr == '_') && ptr < text_limit) { ptr++; }
-        size_t param_name_len = ptr - param_name;
+        size_t param_name_len = (size_t)(ptr - param_name);
         if (!param_name_len) {
             CFCUtil_die("Malformed @param directive in '%s'", raw_text);
         }
@@ -151,7 +151,7 @@ CFCDocuComment_parse(const char *raw_text) {
               ) {
             ptr++;
         }
-        size_t param_doc_len = ptr - param_doc;
+        size_t param_doc_len = (size_t)(ptr - param_doc);
 
         num_params++;
         size_t size = (num_params + 1) * sizeof(char*);

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/91f00051/compiler/src/CFCFile.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCFile.c b/compiler/src/CFCFile.c
index 52a4451..1e03a3e 100644
--- a/compiler/src/CFCFile.c
+++ b/compiler/src/CFCFile.c
@@ -81,7 +81,7 @@ CFCFile_init(CFCFile *self, CFCParcel *parcel, CFCFileSpec *spec) {
             self->guard_name[j++] = '_';
         }
         else if (isalnum(c)) {
-            self->guard_name[j++] = toupper(c);
+            self->guard_name[j++] = (char)toupper(c);
         }
     }
     self->guard_name[j] = '\0';

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/91f00051/compiler/src/CFCGoFunc.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCGoFunc.c b/compiler/src/CFCGoFunc.c
index dbebee8..8607d8f 100644
--- a/compiler/src/CFCGoFunc.c
+++ b/compiler/src/CFCGoFunc.c
@@ -49,9 +49,9 @@ char*
 CFCGoFunc_go_meth_name(const char *orig, int is_public) {
     char *go_name = CFCUtil_strdup(orig);
     if (!is_public) {
-        go_name[0] = tolower(go_name[0]);
+        go_name[0] = (char)tolower(go_name[0]);
     }
-    for (int i = 1, j = 1, max = strlen(go_name) + 1; i < max; i++) {
+    for (size_t i = 1, j = 1, max = strlen(go_name) + 1; i < max; i++) {
         if (go_name[i] != '_') {
             go_name[j++] = go_name[i];
         }
@@ -81,8 +81,8 @@ S_prep_start(CFCParcel *parcel, const char *name, CFCClass *invoker,
 
     char *params = CFCUtil_strdup("");
     char *converted = CFCUtil_strdup("");
-    int start = targ == IS_METHOD ? 1 : 0;
-    for (int i = start; param_vars[i] != NULL; i++) {
+    size_t start = targ == IS_METHOD ? 1 : 0;
+    for (size_t i = start; param_vars[i] != NULL; i++) {
         CFCVariable *var = param_vars[i];
         CFCType *type = CFCVariable_get_type(var);
         char *go_type_name = CFCGoTypeMap_go_type_name(type, parcel);
@@ -96,7 +96,7 @@ S_prep_start(CFCParcel *parcel, const char *name, CFCClass *invoker,
 
     // Convert certain types and defer their destruction until after the
     // Clownfish call returns.
-    for (int i = 0; param_vars[i] != NULL; i++) {
+    for (size_t i = 0; param_vars[i] != NULL; i++) {
         CFCVariable *var = param_vars[i];
         CFCType *type = CFCVariable_get_type(var);
         if (!CFCType_is_object(type)) {
@@ -231,7 +231,7 @@ S_prep_cfargs(CFCParcel *parcel, CFCClass *invoker,
     char go_name[GO_NAME_BUF_SIZE];
     char *cfargs = CFCUtil_strdup("");
 
-    for (int i = 0; vars[i] != NULL; i++) {
+    for (size_t i = 0; vars[i] != NULL; i++) {
         CFCVariable *var = vars[i];
         CFCType *type = CFCVariable_get_type(var);
         if (targ == IS_METHOD && i == 0) {

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/91f00051/compiler/src/CFCGoTypeMap.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCGoTypeMap.c b/compiler/src/CFCGoTypeMap.c
index 4c74863..ad91817 100644
--- a/compiler/src/CFCGoTypeMap.c
+++ b/compiler/src/CFCGoTypeMap.c
@@ -153,7 +153,7 @@ CFCGoTypeMap_go_type_name(CFCType *type, CFCParcel *current_parcel) {
         }
         char *result = CFCUtil_sprintf("%s.%s", package_name, struct_sym);
         for (int i = 0; result[i] != '.'; i++) {
-            result[i] = tolower(result[i]);
+            result[i] = (char)tolower(result[i]);
         }
         return result;
     }
@@ -184,7 +184,7 @@ CFCGoTypeMap_go_short_package(CFCParcel *parcel) {
     // parcel names.
     char *go_short_package = CFCUtil_strdup(parcel_frag);
     for (int i = 0; go_short_package[i] != '\0'; i++) {
-        go_short_package[i] = tolower(go_short_package[i]);
+        go_short_package[i] = (char)tolower(go_short_package[i]);
     }
     return go_short_package;
 }
@@ -207,7 +207,7 @@ CFCGoTypeMap_go_meth_receiever(const char *struct_name,
     // Find the first letter of the type and lowercase it.
     for (size_t i = 0, max = strlen(struct_name); i < max; i++) {
         if (isupper(struct_name[i])) {
-            buf[0] = tolower(struct_name[i]);
+            buf[0] = (char)tolower(struct_name[i]);
             buf[1] = '\0';
             break;
         }
@@ -265,7 +265,7 @@ CFCGoTypeMap_go_arg_name(CFCParamList *param_list, size_t tick, char *buf,
             continue;
         }
         else if (last_was_underscore) {
-            buf[dest_tick] = toupper(orig[i]);
+            buf[dest_tick] = (char)toupper(orig[i]);
         }
         else {
             buf[dest_tick] = orig[i];

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/91f00051/compiler/src/CFCParcel.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCParcel.c b/compiler/src/CFCParcel.c
index 3e2e8ba..cbfd2a5 100644
--- a/compiler/src/CFCParcel.c
+++ b/compiler/src/CFCParcel.c
@@ -209,8 +209,8 @@ CFCParcel_init(CFCParcel *self, const char *name, const char *nickname,
         self->Prefix[nickname_len] = '\0';
     }
     for (size_t i = 0; i < amount; i++) {
-        self->prefix[i] = tolower(self->Prefix[i]);
-        self->PREFIX[i] = toupper(self->Prefix[i]);
+        self->prefix[i] = (char)tolower(self->Prefix[i]);
+        self->PREFIX[i] = (char)toupper(self->Prefix[i]);
     }
     self->prefix[prefix_len] = '\0';
     self->Prefix[prefix_len] = '\0';
@@ -221,7 +221,7 @@ CFCParcel_init(CFCParcel *self, const char *name, const char *nickname,
     self->privacy_sym = (char*)MALLOCATE(privacy_sym_len + 1);
     memcpy(self->privacy_sym, "CFP_", 4);
     for (size_t i = 0; i < nickname_len; i++) {
-        self->privacy_sym[i+4] = toupper(self->nickname[i]);
+        self->privacy_sym[i+4] = (char)toupper(self->nickname[i]);
     }
     self->privacy_sym[privacy_sym_len] = '\0';
 
@@ -776,7 +776,7 @@ S_parse_json_string(const char **json) {
     }
     JSONNode *node = (JSONNode*)calloc(1, sizeof(JSONNode));
     node->type = JSON_STRING;
-    node->string = CFCUtil_strndup(start, text - start);
+    node->string = CFCUtil_strndup(start, (size_t)(text - start));
 
     // Move pointer.
     text++;

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/91f00051/compiler/src/CFCParser.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCParser.c b/compiler/src/CFCParser.c
index a49a6c4..b1c74f7 100644
--- a/compiler/src/CFCParser.c
+++ b/compiler/src/CFCParser.c
@@ -99,7 +99,7 @@ CFCParser_parse(CFCParser *self, const char *string) {
     // Zero out, then parse.
     self->errors = false;
     self->lineno = 0;
-    YY_BUFFER_STATE buffer = yy_scan_bytes(string, (int)strlen(string));
+    YY_BUFFER_STATE buffer = yy_scan_bytes(string, (yy_size_t)strlen(string));
     yylex();
     yy_delete_buffer(buffer);
 

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/91f00051/compiler/src/CFCPerl.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCPerl.c b/compiler/src/CFCPerl.c
index 056afaf..ccd548b 100644
--- a/compiler/src/CFCPerl.c
+++ b/compiler/src/CFCPerl.c
@@ -280,7 +280,7 @@ S_write_boot_h(CFCPerl *self) {
     S_replace_double_colons(guard, '_');
     for (char *ptr = guard; *ptr != '\0'; ptr++) {
         if (isalpha(*ptr)) {
-            *ptr = toupper(*ptr);
+            *ptr = (char)toupper(*ptr);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/91f00051/compiler/src/CFCPerlConstructor.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCPerlConstructor.c b/compiler/src/CFCPerlConstructor.c
index 380cb08..6069aa2 100644
--- a/compiler/src/CFCPerlConstructor.c
+++ b/compiler/src/CFCPerlConstructor.c
@@ -115,7 +115,7 @@ CFCPerlConstructor_xsub_def(CFCPerlConstructor *self, CFCClass *klass)
{
         locate_args = CFCUtil_strdup("");
     }
     else {
-        unsigned num_params = num_vars - 1;
+        unsigned num_params = (unsigned)num_vars - 1;
         items_check = "items < 1";
         param_specs = CFCPerlSub_build_param_specs((CFCPerlSub*)self, 1);
         locs_decl   = CFCUtil_sprintf("    int32_t locations[%u];\n"

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/91f00051/compiler/src/CFCPerlMethod.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCPerlMethod.c b/compiler/src/CFCPerlMethod.c
index c8281ee..f614896 100644
--- a/compiler/src/CFCPerlMethod.c
+++ b/compiler/src/CFCPerlMethod.c
@@ -133,7 +133,7 @@ CFCPerlMethod_perl_name(CFCMethod *method) {
     const char *name      = CFCMethod_get_name(method);
     char       *perl_name = CFCUtil_strdup(name);
     for (size_t i = 0; perl_name[i] != '\0'; i++) {
-        perl_name[i] = tolower(perl_name[i]);
+        perl_name[i] = (char)tolower(perl_name[i]);
     }
 
     return perl_name;

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/91f00051/compiler/src/CFCPerlPod.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCPerlPod.c b/compiler/src/CFCPerlPod.c
index c09eacf..09be538 100644
--- a/compiler/src/CFCPerlPod.c
+++ b/compiler/src/CFCPerlPod.c
@@ -577,14 +577,14 @@ S_camel_to_lower(const char *camel) {
     }
     char *lower = (char*)MALLOCATE(alloc + 1);
 
-    lower[0] = tolower(camel[0]);
+    lower[0] = (char)tolower(camel[0]);
     size_t j = 1;
     for (size_t i = 1; camel[i]; i++) {
         // Only insert underscore if next char is lowercase.
         if (isupper(camel[i]) && islower(camel[i+1])) {
             lower[j++] = '_';
         }
-        lower[j++] = tolower(camel[i]);
+        lower[j++] = (char)tolower(camel[i]);
     }
     lower[j] = '\0';
 
@@ -948,7 +948,7 @@ S_convert_link(cmark_node *link, CFCClass *doc_class, int header_level)
{
 
             char *perl_name = CFCUtil_strdup(name);
             for (size_t i = 0; perl_name[i] != '\0'; ++i) {
-                perl_name[i] = tolower(perl_name[i]);
+                perl_name[i] = (char)tolower(perl_name[i]);
             }
 
             // The Perl POD only contains sections for novel methods. Link

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/91f00051/compiler/src/CFCPerlSub.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCPerlSub.c b/compiler/src/CFCPerlSub.c
index fb50975..2f1d71b 100644
--- a/compiler/src/CFCPerlSub.c
+++ b/compiler/src/CFCPerlSub.c
@@ -51,9 +51,9 @@ CFCPerlSub_init(CFCPerlSub *self, CFCParamList *param_list,
 
     size_t c_name_len = strlen(self->perl_name) + sizeof("XS_") + 1;
     self->c_name = (char*)MALLOCATE(c_name_len);
-    int j = 3;
+    size_t j = 3;
     memcpy(self->c_name, "XS_", j);
-    for (int i = 0, max = (int)strlen(self->perl_name); i < max; i++) {
+    for (size_t i = 0, max = strlen(self->perl_name); i < max; i++) {
         char c = self->perl_name[i];
         if (c == ':') {
             while (self->perl_name[i + 1] == ':') { i++; }

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/91f00051/compiler/src/CFCPyClass.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCPyClass.c b/compiler/src/CFCPyClass.c
index 0fe168e..1e80ebb 100644
--- a/compiler/src/CFCPyClass.c
+++ b/compiler/src/CFCPyClass.c
@@ -204,7 +204,7 @@ S_pytype_struct_def(CFCPyClass *self) {
     char *pymod_name = CFCUtil_strdup(parcel_name);
     // TODO: Stop lowercasing when parcels are restricted to lowercase.
     for (int i = 0; pymod_name[i] != '\0'; i++) {
-        pymod_name[i] = tolower(pymod_name[i]);
+        pymod_name[i] = (char)tolower(pymod_name[i]);
     }
 
     const char *struct_sym = CFCClass_get_struct_sym(klass);

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/91f00051/compiler/src/CFCPyMethod.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCPyMethod.c b/compiler/src/CFCPyMethod.c
index 45b0f86..168bfb8 100644
--- a/compiler/src/CFCPyMethod.c
+++ b/compiler/src/CFCPyMethod.c
@@ -50,12 +50,12 @@ S_maybe_unreachable(CFCType *return_type);
 
 static char*
 S_build_py_args(CFCParamList *param_list) {
-    int num_vars = CFCParamList_num_vars(param_list);
+    size_t num_vars = CFCParamList_num_vars(param_list);
     CFCVariable **vars = CFCParamList_get_variables(param_list);
     char pattern[] = "    PyObject *cfcb_ARGS = S_pack_tuple(%d";
     char *py_args = CFCUtil_sprintf(pattern, num_vars - 1);
 
-    for (int i = 1; vars[i] != NULL; i++) {
+    for (size_t i = 1; vars[i] != NULL; i++) {
         const char *var_name = CFCVariable_get_name(vars[i]);
         CFCType *type = CFCVariable_get_type(vars[i]);
         char *conversion = CFCPyTypeMap_c_to_py(type, var_name);
@@ -70,9 +70,9 @@ S_build_py_args(CFCParamList *param_list) {
 static char*
 S_gen_decs(CFCParamList *param_list, int first_tick) {
     char *decs = CFCUtil_strdup("");
-    int num_vars = CFCParamList_num_vars(param_list);
+    size_t num_vars = CFCParamList_num_vars(param_list);
     CFCVariable **vars = CFCParamList_get_variables(param_list);
-    for (int i = first_tick; i < num_vars; i++) {
+    for (int i = first_tick; i < (int)num_vars; i++) {
         CFCType *type = CFCVariable_get_type(vars[i]);
         const char *name = CFCVariable_get_name(vars[i]);
         decs = CFCUtil_cat(decs, "    ", CFCType_to_c(type), " ", name,
@@ -192,7 +192,7 @@ S_gen_arg_parsing(CFCParamList *param_list, int first_tick, char **error)
{
 
     CFCVariable **vars = CFCParamList_get_variables(param_list);
     const char **vals = CFCParamList_get_initial_values(param_list);
-    int num_vars = CFCParamList_num_vars(param_list);
+    size_t num_vars = CFCParamList_num_vars(param_list);
 
     char *declarations = CFCUtil_strdup("");
     char *keywords     = CFCUtil_strdup("");
@@ -200,7 +200,7 @@ S_gen_arg_parsing(CFCParamList *param_list, int first_tick, char **error)
{
     char *targets      = CFCUtil_strdup("");
     int optional_started = 0;
 
-    for (int i = first_tick; i < num_vars; i++) {
+    for (int i = first_tick; i < (int)num_vars; i++) {
         CFCVariable *var  = vars[i];
         const char  *val  = vals[i];
 
@@ -276,8 +276,8 @@ S_build_pymeth_invocation(CFCMethod *method) {
         if (strlen(ret_type_str) > 63) {
             CFCUtil_die("Unexpectedly long type name: %s", ret_type_str);
         }
-        for (int i = 0, max = strlen(ret_type_str) + 1; i < max; i++) {
-            type_upcase[i] = toupper(ret_type_str[i]);
+        for (size_t i = 0, max = strlen(ret_type_str) + 1; i < max; i++) {
+            type_upcase[i] = (char)toupper(ret_type_str[i]);
         }
         const char pattern[] =
             "    %s cfcb_RESULT = CALL_PYMETH_%s((PyObject*)self, \"%s\", cfcb_ARGS);";
@@ -433,9 +433,9 @@ S_meth_top(CFCMethod *method) {
 static char*
 S_gen_arg_increfs(CFCParamList *param_list, int first_tick) {
     CFCVariable **vars = CFCParamList_get_variables(param_list);
-    int num_vars = CFCParamList_num_vars(param_list);
+    size_t num_vars = CFCParamList_num_vars(param_list);
     char *content = CFCUtil_strdup("");
-    for (int i = first_tick;i < num_vars; i++) {
+    for (size_t i = (size_t)first_tick; i < num_vars; i++) {
         CFCType *type = CFCVariable_get_type(vars[i]);
         if (CFCType_decremented(type)) {
             const char *name = CFCVariable_get_name(vars[i]);
@@ -455,10 +455,10 @@ S_gen_arg_increfs(CFCParamList *param_list, int first_tick) {
 static char*
 S_gen_decrefs(CFCParamList *param_list, int first_tick) {
     CFCVariable **vars = CFCParamList_get_variables(param_list);
-    int num_vars = CFCParamList_num_vars(param_list);
+    size_t num_vars = CFCParamList_num_vars(param_list);
     char *decrefs = CFCUtil_strdup("");
 
-    for (int i = first_tick; i < num_vars; i++) {
+    for (size_t i = (size_t)first_tick; i < num_vars; i++) {
         CFCVariable *var = vars[i];
         CFCType *type = CFCVariable_get_type(var);
         const char *micro_sym = CFCVariable_get_name(var);
@@ -480,9 +480,9 @@ S_gen_decrefs(CFCParamList *param_list, int first_tick) {
 static char*
 S_gen_arg_list(CFCParamList *param_list, const char *first_arg) {
     CFCVariable **vars = CFCParamList_get_variables(param_list);
-    int num_vars = CFCParamList_num_vars(param_list);
+    size_t num_vars = CFCParamList_num_vars(param_list);
     char *arg_list = CFCUtil_strdup("");
-    for (int i = 0; i < num_vars; i++) {
+    for (size_t i = 0; i < num_vars; i++) {
         if (i > 0) {
             arg_list = CFCUtil_cat(arg_list, ", ", NULL);
         }
@@ -646,7 +646,7 @@ CFCPyMethod_pymethoddef(CFCMethod *method, CFCClass *invoker) {
     char *meth_sym = CFCMethod_full_method_sym(method, invoker);
     char *micro_sym = CFCUtil_strdup(CFCSymbol_get_name((CFCSymbol*)method));
     for (int i = 0; micro_sym[i] != 0; i++) {
-        micro_sym[i] = tolower(micro_sym[i]);
+        micro_sym[i] = (char)tolower(micro_sym[i]);
     }
 
     char pattern[] =

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/91f00051/compiler/src/CFCPython.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCPython.c b/compiler/src/CFCPython.c
index 3c60682..0dff7e2 100644
--- a/compiler/src/CFCPython.c
+++ b/compiler/src/CFCPython.c
@@ -447,7 +447,7 @@ S_write_module_file(CFCPython *self, CFCParcel *parcel, const char *dest)
{
     char *pymod_name = CFCUtil_strdup(parcel_name);
     // TODO: Stop lowercasing when parcels are restricted to lowercase.
     for (int i = 0; pymod_name[i] != '\0'; i++) {
-        pymod_name[i] = tolower(pymod_name[i]);
+        pymod_name[i] = (char)tolower(pymod_name[i]);
     }
     const char *last_dot = strrchr(pymod_name, '.');
     const char *last_component = last_dot != NULL
@@ -455,7 +455,7 @@ S_write_module_file(CFCPython *self, CFCParcel *parcel, const char *dest)
{
                                  : pymod_name;
     char *helper_mod_name = CFCUtil_sprintf("%s._%s", pymod_name, last_component);
     for (int i = 0; helper_mod_name[i] != '\0'; i++) {
-        helper_mod_name[i] = tolower(helper_mod_name[i]);
+        helper_mod_name[i] = (char)tolower(helper_mod_name[i]);
     }
 
     CFCClass  **ordered = CFCHierarchy_ordered_classes(self->hierarchy);

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/91f00051/compiler/src/CFCRuby.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCRuby.c b/compiler/src/CFCRuby.c
index ec3dd9a..0e2c146 100644
--- a/compiler/src/CFCRuby.c
+++ b/compiler/src/CFCRuby.c
@@ -135,7 +135,7 @@ S_write_boot_h(CFCRuby *self) {
     S_replace_double_colons(guard, '_');
     for (char *ptr = guard; *ptr != '\0'; ptr++) {
         if (isalpha(*ptr)) {
-            *ptr = toupper(*ptr);
+            *ptr = (char)toupper(*ptr);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/91f00051/compiler/src/CFCType.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCType.c b/compiler/src/CFCType.c
index 87f1a85..a45c174 100644
--- a/compiler/src/CFCType.c
+++ b/compiler/src/CFCType.c
@@ -384,7 +384,7 @@ CFCType_get_class_var(CFCType *self) {
     if (!self->class_var) {
         self->class_var = CFCUtil_strdup(self->specifier);
         for (int i = 0; self->class_var[i] != 0; i++) {
-            self->class_var[i] = toupper(self->class_var[i]);
+            self->class_var[i] = (char)toupper(self->class_var[i]);
         }
     }
     return self->class_var;
@@ -410,7 +410,7 @@ CFCType_to_c(CFCType *self) {
         // NOTE: Array postfixes are NOT included.
         const char *child_c_string = CFCType_to_c(self->child);
         size_t      child_c_len    = strlen(child_c_string);
-        size_t      amount         = child_c_len + self->indirection;
+        size_t      amount         = child_c_len + (size_t)self->indirection;
         c_string = (char*)MALLOCATE(amount + 1);
         strcpy(c_string, child_c_string);
         for (int i = 0; i < self->indirection; i++) {

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/91f00051/compiler/src/CFCUtil.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCUtil.c b/compiler/src/CFCUtil.c
index 7470c04..f505cac 100644
--- a/compiler/src/CFCUtil.c
+++ b/compiler/src/CFCUtil.c
@@ -16,6 +16,7 @@
 
 #include "charmony.h"
 
+#include <stddef.h>
 #include <string.h>
 #include <stdlib.h>
 #include <ctype.h>
@@ -155,32 +156,32 @@ CFCUtil_global_replace(const char *string, const char *match,
     int   len_diff        = replacement_len - match_len;
 
     // Allocate space.
-    unsigned count = 0;
+    int count = 0;
     while (NULL != (found = strstr(found, match))) {
         count++;
         found += match_len;
     }
     int size = string_len + count * len_diff + 1;
-    char *modified = (char*)MALLOCATE(size);
+    char *modified = (char*)MALLOCATE((size_t)size);
     modified[size - 1] = 0; // NULL-terminate.
 
     // Iterate through all matches.
     found = (char*)string;
     char *target = modified;
-    size_t last_end = 0;
+    ptrdiff_t last_end = 0;
     if (count) {
         while (NULL != (found = strstr(found, match))) {
-            size_t pos = found - string;
-            size_t unchanged_len = pos - last_end;
+            ptrdiff_t pos = found - string;
+            ptrdiff_t unchanged_len = pos - last_end;
             found += match_len;
-            memcpy(target, string + last_end, unchanged_len);
+            memcpy(target, string + last_end, (size_t)unchanged_len);
             target += unchanged_len;
             last_end = pos + match_len;
-            memcpy(target, replacement, replacement_len);
+            memcpy(target, replacement, (size_t)replacement_len);
             target += replacement_len;
         }
     }
-    size_t remaining = string_len - last_end;
+    size_t remaining = (size_t)(string_len - last_end);
     memcpy(target, string + string_len - remaining, remaining);
 
     return modified;
@@ -205,7 +206,7 @@ CFCUtil_enclose_lines(const char *text, const char *line_prefix,
     while (line_start < text_end) {
         const char *line_end = strchr(line_start, '\n');
         const char *next_start;
-        size_t      line_len;
+        ptrdiff_t   line_len;
 
         if (line_end == NULL) {
             line_len   = text_end - line_start;
@@ -216,8 +217,8 @@ CFCUtil_enclose_lines(const char *text, const char *line_prefix,
             next_start = line_end + 1;
         }
 
-        char *line = (char*)MALLOCATE(line_len + 1);
-        memcpy(line, line_start, line_len);
+        char *line = (char*)MALLOCATE((size_t)line_len + 1);
+        memcpy(line, line_start, (size_t)line_len);
         line[line_len] = '\0';
         result = CFCUtil_cat(result, line_prefix, line, line_postfix, "\n",
                              NULL);
@@ -353,7 +354,7 @@ CFCUtil_slurp_text(const char *file_path, size_t *len_ptr) {
     }
 
     /* Find length; return NULL if the file has a zero-length. */
-    binary_len = CFCUtil_flength(file);
+    binary_len = (size_t)CFCUtil_flength(file);
     if (binary_len == 0) {
         *len_ptr = 0;
         return NULL;

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/91f00051/compiler/src/CFCVersion.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCVersion.c b/compiler/src/CFCVersion.c
index 671ff36..97727a8 100644
--- a/compiler/src/CFCVersion.c
+++ b/compiler/src/CFCVersion.c
@@ -60,7 +60,8 @@ CFCVersion_init(CFCVersion *self, const char *vstring) {
     self->numbers = (uint32_t*)CALLOCATE(1, sizeof(uint32_t));
     while (1) {
         if (isdigit(*vstring)) {
-            num = num * 10 + *vstring - '0';
+            int digit = *vstring - '0';
+            num = num * 10 + (uint32_t)digit;
         }
         else {
             if (*vstring != 0 && *vstring != '.') {


Mime
View raw message