[Rprotobuf-commits] r671 - in pkg: . src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Dec 31 13:31:12 CET 2013


Author: murray
Date: 2013-12-31 13:31:11 +0100 (Tue, 31 Dec 2013)
New Revision: 671

Modified:
   pkg/ChangeLog
   pkg/src/DescriptorPoolLookup.cpp
   pkg/src/extensions.cpp
   pkg/src/wrapper_Descriptor.cpp
   pkg/src/wrapper_FieldDescriptor.cpp
   pkg/src/wrapper_FileDescriptor.cpp
Log:
More Flexelint cleanup.  Remove unused variables (masked in a way as
compilers with -Wall didn't catch this), unreachable statements, an
unused header, etc.



Modified: pkg/ChangeLog
===================================================================
--- pkg/ChangeLog	2013-12-31 12:07:37 UTC (rev 670)
+++ pkg/ChangeLog	2013-12-31 12:31:11 UTC (rev 671)
@@ -8,6 +8,13 @@
 	  support.  All of these fixes were highlighted by Flexelint.
 	* inst/unitTests/runit.int64.R (test.int64): Add tests for above.
 	* inst/unitTests/runit.extremevalues.R (test.uint32): Idem.
+	* src/wrapper_FieldDescriptor.cpp (RPB_HANDLE_CASE): Remove
+	  unreachable statement in a macro.
+	* src/wrapper_Descriptor.cpp (rprotobuf): Remove unused variable,
+	  rename another variable for clarity, and add some TODOs.
+	* src/wrapper_FileDescriptor.cpp (rprotobuf): Idem.
+	* src/DescriptorPoolLookup.cpp (rprotobuf): Remove unreachable statement.
+	* src/extensions.cpp: Remove unused header.
 
 2013-12-30  Murray Stokely  <mstokely at google.com>
 

Modified: pkg/src/DescriptorPoolLookup.cpp
===================================================================
--- pkg/src/DescriptorPoolLookup.cpp	2013-12-31 12:07:37 UTC (rev 670)
+++ pkg/src/DescriptorPoolLookup.cpp	2013-12-31 12:31:11 UTC (rev 671)
@@ -52,7 +52,6 @@
             std::string message = std::string("Could not load proto file '") + CHAR(STRING_ELT(files, j)) +
                 "'\n";
             Rcpp_error(message.c_str());
-            continue;
         }
         int ntypes = file_desc->message_type_count();
         for (int i = 0; i < ntypes; i++) {

Modified: pkg/src/extensions.cpp
===================================================================
--- pkg/src/extensions.cpp	2013-12-31 12:07:37 UTC (rev 670)
+++ pkg/src/extensions.cpp	2013-12-31 12:31:11 UTC (rev 671)
@@ -20,7 +20,6 @@
  */
 
 #include "rprotobuf.h"
-#include "fieldtypes.h"
 #include "Rcppsupport.h"
 
 namespace rprotobuf {

Modified: pkg/src/wrapper_Descriptor.cpp
===================================================================
--- pkg/src/wrapper_Descriptor.cpp	2013-12-31 12:07:37 UTC (rev 670)
+++ pkg/src/wrapper_Descriptor.cpp	2013-12-31 12:31:11 UTC (rev 671)
@@ -54,22 +54,21 @@
 
     Rcpp::CharacterVector names(n);
     Rcpp::List res(n);
-    int i = 0;
-    int j = 0;
-    for (i = 0; i < nfields; j++, i++) {
+    int cnt = 0;
+    for (i = 0; i < nfields; cnt++, i++) {
         const GPB::FieldDescriptor* fd = desc->field(i);
-        res[j] = S4_FieldDescriptor(fd);
-        names[j] = fd->name();
+        res[cnt] = S4_FieldDescriptor(fd);
+        names[cnt] = fd->name();
     }
-    for (i = 0; i < ntypes; j++, i++) {
+    for (i = 0; i < ntypes; cnt++, i++) {
         const GPB::Descriptor* d = desc->nested_type(i);
-        res[j] = S4_Descriptor(d);
-        names[j] = d->name();
+        res[cnt] = S4_Descriptor(d);
+        names[cnt] = d->name();
     }
-    for (i = 0; i < nenums; j++, i++) {
+    for (i = 0; i < nenums; cnt++, i++) {
         const GPB::EnumDescriptor* ed = desc->enum_type(i);
-        res[j] = S4_EnumDescriptor(ed);
-        names[j] = ed->name();
+        res[cnt] = S4_EnumDescriptor(ed);
+        names[cnt] = ed->name();
     }
     res.names() = names;
 
@@ -135,6 +134,7 @@
     }
 
     /* read the message from the file */
+    // TODO(mstokely): Check return value!
     message->ParsePartialFromFileDescriptor(file);
     close(file);
     return (S4_Message(message));
@@ -151,6 +151,7 @@
     if (!message) {
         throw std::range_error("could not call factory->GetPrototype(desc)->New()");
     }
+    // TODO(mstokely): Check return value!
     message->ParsePartialFromCodedStream(&coded_stream);
 
     S4_Message res(message);

Modified: pkg/src/wrapper_FieldDescriptor.cpp
===================================================================
--- pkg/src/wrapper_FieldDescriptor.cpp	2013-12-31 12:07:37 UTC (rev 670)
+++ pkg/src/wrapper_FieldDescriptor.cpp	2013-12-31 12:31:11 UTC (rev 671)
@@ -42,7 +42,6 @@
 #define RPB_HANDLE_CASE(__CPP__, __LC__)                \
     case CPPTYPE_##__CPP__: {                           \
         return Rcpp::wrap(d->default_value_##__LC__()); \
-        break;                                          \
     }
 
 RPB_FUNCTION_1(SEXP, METHOD(default_value), Rcpp::XPtr<GPB::FieldDescriptor> d) {
@@ -61,7 +60,6 @@
 
         case CPPTYPE_ENUM: {
             return Rf_ScalarInteger(d->default_value_enum()->number());
-            break;
         }
         default:
             break;

Modified: pkg/src/wrapper_FileDescriptor.cpp
===================================================================
--- pkg/src/wrapper_FileDescriptor.cpp	2013-12-31 12:07:37 UTC (rev 670)
+++ pkg/src/wrapper_FileDescriptor.cpp	2013-12-31 12:31:11 UTC (rev 671)
@@ -63,24 +63,23 @@
 
     Rcpp::CharacterVector names(n);
     Rcpp::List res(n);
-    int i = 0;
-    int j = 0;
-    for (i = 0; i < ntypes; j++, i++) {
-        res[j] = S4_Descriptor(desc->message_type(i));
-        names[j] = desc->message_type(i)->name();
+    int count = 0;
+    for (i = 0; i < ntypes; count++, i++) {
+        res[count] = S4_Descriptor(desc->message_type(i));
+        names[count] = desc->message_type(i)->name();
     }
-    for (i = 0; i < nenums; j++, i++) {
-        res[j] = S4_EnumDescriptor(desc->enum_type(i));
-        names[j] = desc->enum_type(i)->name();
+    for (i = 0; i < nenums; count++, i++) {
+        res[count] = S4_EnumDescriptor(desc->enum_type(i));
+        names[count] = desc->enum_type(i)->name();
     }
-    for (i = 0; i < nserv; j++, i++) {
-        res[j] = S4_ServiceDescriptor(desc->service(i));
-        names[j] = desc->service(i)->name();
+    for (i = 0; i < nserv; count++, i++) {
+        res[count] = S4_ServiceDescriptor(desc->service(i));
+        names[count] = desc->service(i)->name();
     }
-    for (i = 0; i < nexts; j++, i++) {
-        res[j] = S4_FieldDescriptor(desc->extension(i));
+    for (i = 0; i < nexts; count++, i++) {
+        res[count] = S4_FieldDescriptor(desc->extension(i));
         // always use full names for extensions
-        names[j] = desc->extension(i)->full_name();
+        names[count] = desc->extension(i)->full_name();
     }
     res.names() = names;
     return res;



More information about the Rprotobuf-commits mailing list