aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Josh Haberman <jhaberman@gmail.com>2015-06-09 11:08:25 -0700
committerGravatar Josh Haberman <jhaberman@gmail.com>2015-06-09 11:08:25 -0700
commite3ce451b6047941cd574d3f70a7e4c2d150c6f20 (patch)
treeab828174fafb210acfebe2e2ccb3353c46faf832
parente8ed021ee717cb8cc4e9de68e61d4dae2e1dd832 (diff)
Fixed compiler warnings and added -std=c99.
upb no longer requires -std=c99 but the Ruby/C code still uses C99 features.
-rw-r--r--ruby/ext/google/protobuf_c/defs.c15
-rw-r--r--ruby/ext/google/protobuf_c/extconf.rb2
2 files changed, 7 insertions, 10 deletions
diff --git a/ruby/ext/google/protobuf_c/defs.c b/ruby/ext/google/protobuf_c/defs.c
index e3341cca..8f9f33e2 100644
--- a/ruby/ext/google/protobuf_c/defs.c
+++ b/ruby/ext/google/protobuf_c/defs.c
@@ -546,11 +546,9 @@ upb_fieldtype_t ruby_to_fieldtype(VALUE type) {
rb_raise(rb_eArgError, "Expected symbol for field type.");
}
- upb_fieldtype_t upb_type = -1;
-
#define CONVERT(upb, ruby) \
if (SYM2ID(type) == rb_intern( # ruby )) { \
- upb_type = UPB_TYPE_ ## upb; \
+ return UPB_TYPE_ ## upb; \
}
CONVERT(FLOAT, float);
@@ -567,11 +565,8 @@ upb_fieldtype_t ruby_to_fieldtype(VALUE type) {
#undef CONVERT
- if (upb_type == -1) {
- rb_raise(rb_eArgError, "Unknown field type.");
- }
-
- return upb_type;
+ rb_raise(rb_eArgError, "Unknown field type.");
+ return 0;
}
VALUE fieldtype_to_ruby(upb_fieldtype_t type) {
@@ -666,10 +661,12 @@ VALUE FieldDescriptor_label_set(VALUE _self, VALUE label) {
}
upb_label_t upb_label = -1;
+ bool converted = false;
#define CONVERT(upb, ruby) \
if (SYM2ID(label) == rb_intern( # ruby )) { \
upb_label = UPB_LABEL_ ## upb; \
+ converted = true; \
}
CONVERT(OPTIONAL, optional);
@@ -678,7 +675,7 @@ VALUE FieldDescriptor_label_set(VALUE _self, VALUE label) {
#undef CONVERT
- if (upb_label == -1) {
+ if (!converted) {
rb_raise(rb_eArgError, "Unknown field label.");
}
diff --git a/ruby/ext/google/protobuf_c/extconf.rb b/ruby/ext/google/protobuf_c/extconf.rb
index 9675f57f..b368dcc6 100644
--- a/ruby/ext/google/protobuf_c/extconf.rb
+++ b/ruby/ext/google/protobuf_c/extconf.rb
@@ -2,7 +2,7 @@
require 'mkmf'
-$CFLAGS += " -O3 -DNDEBUG"
+$CFLAGS += " -std=c99 -O3 -DNDEBUG"
$objs = ["protobuf.o", "defs.o", "storage.o", "message.o",
"repeated_field.o", "map.o", "encode_decode.o", "upb.o"]