-----Ursprüngliche Nachricht----- From: [email protected] Sent: Sunday, August 24, 2014 1:00 AM Subject: New Defects reported by Coverity Scan for thrift


Hi,


Please find the latest report on new defect(s) introduced to thrift found with Coverity Scan.

Defect(s) Reported-by: Coverity Scan
Showing 11 of 11 defect(s)


** CID 1232628:  Logically dead code  (DEADCODE)
/compiler/cpp/src/generate/t_hs_generator.cc: 775 in t_hs_generator::generate_hs_struct_writer(std::basic_ofstream<char, std::char_traits<char>> &, t_struct *)() /compiler/cpp/src/generate/t_hs_generator.cc: 841 in t_hs_generator::generate_hs_struct_writer(std::basic_ofstream<char, std::char_traits<char>> &, t_struct *)()

** CID 1232627:  Logically dead code  (DEADCODE)
/compiler/cpp/src/generate/t_hs_generator.cc: 838 in t_hs_generator::generate_hs_struct_writer(std::basic_ofstream<char, std::char_traits<char>> &, t_struct *)()

** CID 1232629:  Resource leak  (RESOURCE_LEAK)
/compiler/cpp/src/thriftl.ll: 386 in yylex()

** CID 1232637:  Unused pointer value  (UNUSED_VALUE)
/compiler/cpp/src/generate/t_hs_generator.cc: 1156 in t_hs_generator::generate_service_client(t_service *)()

** CID 1232636:  Unused pointer value  (UNUSED_VALUE)
/compiler/cpp/src/generate/t_hs_generator.cc: 454 in t_hs_generator::render_const_value(t_type *, t_const_value *)()

** CID 1232635:  Unused pointer value  (UNUSED_VALUE)
/compiler/cpp/src/generate/t_hs_generator.cc: 457 in t_hs_generator::render_const_value(t_type *, t_const_value *)()

** CID 1232634:  Unused pointer value  (UNUSED_VALUE)
/compiler/cpp/src/generate/t_hs_generator.cc: 966 in t_hs_generator::generate_hs_default(std::basic_ofstream<char, std::char_traits<char>> &, t_struct *)()

** CID 1232633:  Unused pointer value  (UNUSED_VALUE)
/compiler/cpp/src/generate/t_hs_generator.cc: 938 in t_hs_generator::generate_hs_typemap(std::basic_ofstream<char, std::char_traits<char>> &, t_struct *)()

** CID 1232632:  Unused pointer value  (UNUSED_VALUE)
/compiler/cpp/src/generate/t_hs_generator.cc: 680 in t_hs_generator::generate_hs_struct_reader(std::basic_ofstream<char, std::char_traits<char>> &, t_struct *)()

** CID 1232630:  Uninitialized pointer field  (UNINIT_CTOR)
/compiler/cpp/src/generate/t_csharp_generator.cc: 91 in t_csharp_generator::t_csharp_generator(t_program *, const std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::basic_string<char, std::char_traits<char>, std::allocator<char>>>>> &, const std::basic_string<char, std::char_traits<char>, std::allocator<char>>&)()

** CID 1232631:  Unused pointer value  (UNUSED_VALUE)
/compiler/cpp/src/generate/t_hs_generator.cc: 754 in t_hs_generator::generate_hs_struct_writer(std::basic_ofstream<char, std::char_traits<char>> &, t_struct *)()


________________________________________________________________________________________________________
*** CID 1232628:  Logically dead code  (DEADCODE)
/compiler/cpp/src/generate/t_hs_generator.cc: 775 in t_hs_generator::generate_hs_struct_writer(std::basic_ofstream<char, std::char_traits<char>> &, t_struct *)()
769           break;
770         }
771       }
772
773       bool isfirst = true;
774       if (hasExn) {
    CID 1232628:  Logically dead code  (DEADCODE)
    Execution cannot reach this statement "out << endl;".
775         out << endl;
776         indent(out) << "(let exns = M.catMaybes ";
777         indent_up();
778         for (auto* f_iter : fields) {
779           if (((t_type*)f_iter->get_type())->is_xception()) {
780     if (isfirst) {
/compiler/cpp/src/generate/t_hs_generator.cc: 841 in t_hs_generator::generate_hs_struct_writer(std::basic_ofstream<char, std::char_traits<char>> &, t_struct *)()
835       if (isfirst) {
836         indent(out) << "[]" << endl;
837       } else {
838         indent(out) << "]" << endl;
839       }
840       if (hasExn) {
    CID 1232628:  Logically dead code  (DEADCODE)
Execution cannot reach this statement "(this->indent(out) << ")") ...".
841         indent(out) << ")" << endl;
842         indent_down();
843       }
844       indent_down();
845
846       // write

________________________________________________________________________________________________________
*** CID 1232627:  Logically dead code  (DEADCODE)
/compiler/cpp/src/generate/t_hs_generator.cc: 838 in t_hs_generator::generate_hs_struct_writer(std::basic_ofstream<char, std::char_traits<char>> &, t_struct *)()
832       }
833
834       // Write the struct map
835       if (isfirst) {
836         indent(out) << "[]" << endl;
837       } else {
    CID 1232627:  Logically dead code  (DEADCODE)
Execution cannot reach this statement "(this->indent(out) << "]") ...".
838         indent(out) << "]" << endl;
839       }
840       if (hasExn) {
841         indent(out) << ")" << endl;
842         indent_down();
843       }

________________________________________________________________________________________________________
*** CID 1232629:  Resource leak  (RESOURCE_LEAK)
/compiler/cpp/src/thriftl.ll: 386 in yylex()
380
381     {doctext} {
382      /* This does not show up in the parse tree. */
383      /* Rather, the parser will grab it out of the global. */
384       if (g_parse_mode == PROGRAM) {
385         clear_doctext();
    CID 1232629:  Resource leak  (RESOURCE_LEAK)
Overwriting "g_doctext" in "g_doctext = strdup(&yytext[3])" leaks the storage that "g_doctext" points to.
386         g_doctext = strdup(yytext + 3);
387         assert(strlen(g_doctext) >= 2);
388         g_doctext[strlen(g_doctext) - 2] = ' ';
389         g_doctext[strlen(g_doctext) - 1] = '\0';
390         g_doctext = clean_up_doctext(g_doctext);
391         g_doctext_lineno = yylineno;

________________________________________________________________________________________________________
*** CID 1232637:  Unused pointer value  (UNUSED_VALUE)
/compiler/cpp/src/generate/t_hs_generator.cc: 1156 in t_hs_generator::generate_service_client(t_service *)() 1150 indent(f_client_) << "M.when (mtype == T.M_EXCEPTION) $ do { exn <- T.readAppExn ip ; T.readMessageEnd ip ; X.throw exn }" << endl;
1151
1152 indent(f_client_) << "res <- read_" << resultname << " ip" << endl;
1153           indent(f_client_) << "T.readMessageEnd ip" << endl;
1154
1155           t_struct* xs = (*f_iter)->get_xceptions();
    CID 1232637:  Unused pointer value  (UNUSED_VALUE)
    Pointer "xceptions" returned by "xs->get_members()" is never used.
1156           const vector<t_field*>& xceptions = xs->get_members();
1157
1158           for (auto x_iter : xceptions) {
1159     indent(f_client_) << "P.maybe (P.return ()) X.throw ("
1160       << field_name(resultname, x_iter->get_name())
1161       << " res)" << endl;

________________________________________________________________________________________________________
*** CID 1232636:  Unused pointer value  (UNUSED_VALUE)
/compiler/cpp/src/generate/t_hs_generator.cc: 454 in t_hs_generator::render_const_value(t_type *, t_const_value *)()
448         }
449
450       } else if (type->is_struct() || type->is_xception()) {
451         string cname = type_name(type);
452         out << "default_" << cname << "{";
453
    CID 1232636:  Unused pointer value  (UNUSED_VALUE)
Pointer "fields" returned by "((t_struct *)type)->get_members()" is never used.
454 const vector<t_field*>& fields = ((t_struct*)type)->get_members();
455         vector<t_field*>::const_iterator f_iter;
456
457 const map<t_const_value*, t_const_value*>& val = value->get_map();
458         map<t_const_value*, t_const_value*>::const_iterator v_iter;
459

________________________________________________________________________________________________________
*** CID 1232635:  Unused pointer value  (UNUSED_VALUE)
/compiler/cpp/src/generate/t_hs_generator.cc: 457 in t_hs_generator::render_const_value(t_type *, t_const_value *)()
451         string cname = type_name(type);
452         out << "default_" << cname << "{";
453
454 const vector<t_field*>& fields = ((t_struct*)type)->get_members();
455         vector<t_field*>::const_iterator f_iter;
456
    CID 1232635:  Unused pointer value  (UNUSED_VALUE)
    Pointer "val" returned by "value->get_map()" is never used.
457 const map<t_const_value*, t_const_value*>& val = value->get_map();
458         map<t_const_value*, t_const_value*>::const_iterator v_iter;
459
460         bool first = true;
461         for (auto& v_iter : val) {
462           t_field* field = nullptr;

________________________________________________________________________________________________________
*** CID 1232634:  Unused pointer value  (UNUSED_VALUE)
/compiler/cpp/src/generate/t_hs_generator.cc: 966 in t_hs_generator::generate_hs_default(std::basic_ofstream<char, std::char_traits<char>> &, t_struct *)()
960      * @param tstruct the Struct
961      */
962     void t_hs_generator::generate_hs_default(ofstream& out,
963                                              t_struct* tstruct) {
964       string name = type_name(tstruct);
965       string fname = type_name(tstruct, "default_");
    CID 1232634:  Unused pointer value  (UNUSED_VALUE)
Pointer "fields" returned by "tstruct->get_sorted_members()" is never used.
966       const auto& fields = tstruct->get_sorted_members();
967       vector<t_field*>::const_iterator f_iter;
968
969       indent(out) << fname << " :: " << name << endl;
970       indent(out) << fname << " = " << name << "{" << endl;
971       indent_up();

________________________________________________________________________________________________________
*** CID 1232633:  Unused pointer value  (UNUSED_VALUE)
/compiler/cpp/src/generate/t_hs_generator.cc: 938 in t_hs_generator::generate_hs_typemap(std::basic_ofstream<char, std::char_traits<char>> &, t_struct *)()
932      * Generate the map from field names to (type, id)
933      * @param tstruct the Struct
934      */
935     void t_hs_generator::generate_hs_typemap(ofstream& out,
936                                              t_struct* tstruct) {
937       string name = type_name(tstruct);
    CID 1232633:  Unused pointer value  (UNUSED_VALUE)
Pointer "fields" returned by "tstruct->get_sorted_members()" is never used.
938       const auto& fields = tstruct->get_sorted_members();
939       vector<t_field*>::const_iterator f_iter;
940
941       indent(out) << "typemap_" << name << " :: T.TypeMap" << endl;
942       indent(out) << "typemap_" << name << " = Map.fromList [";
943       bool first = true;

________________________________________________________________________________________________________
*** CID 1232632:  Unused pointer value  (UNUSED_VALUE)
/compiler/cpp/src/generate/t_hs_generator.cc: 680 in t_hs_generator::generate_hs_struct_reader(std::basic_ofstream<char, std::char_traits<char>> &, t_struct *)()
674     }
675
676     /**
677      * Generates the read method for a struct
678      */
679 void t_hs_generator::generate_hs_struct_reader(ofstream& out, t_struct* tstruct) {
    CID 1232632:  Unused pointer value  (UNUSED_VALUE)
    Pointer "fields" returned by "tstruct->get_members()" is never used.
680       const vector<t_field*>& fields = tstruct->get_members();
681       vector<t_field*>::const_iterator f_iter;
682
683       string sname = type_name(tstruct);
684       string id = tmp("_id");
685       string val = tmp("_val");

________________________________________________________________________________________________________
*** CID 1232630:  Uninitialized pointer field  (UNINIT_CTOR)
/compiler/cpp/src/generate/t_csharp_generator.cc: 91 in t_csharp_generator::t_csharp_generator(t_program *, const std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::basic_string<char, std::char_traits<char>, std::allocator<char>>>>> &, const std::basic_string<char, std::char_traits<char>, std::allocator<char>>&)()
85           wcf_ = (iter != parsed_options.end());
86           if (wcf_) {
87             wcf_namespace_ = iter->second;
88           }
89
90           out_dir_base_ = "gen-csharp";
    CID 1232630:  Uninitialized pointer field  (UNINIT_CTOR)
Non-static class member "member_mapping_scope" is not initialized in this constructor nor in any functions that it calls.
91         }
92         void init_generator();
93         void close_generator();
94
95         void generate_consts(std::vector<t_const*> consts);
96

________________________________________________________________________________________________________
*** CID 1232631:  Unused pointer value  (UNUSED_VALUE)
/compiler/cpp/src/generate/t_hs_generator.cc: 754 in t_hs_generator::generate_hs_struct_writer(std::basic_ofstream<char, std::char_traits<char>> &, t_struct *)() 748 out << "T.deserializeVal iprot (T.T_STRUCT " << tmap << ") bs" << endl;
749     }
750
751     void t_hs_generator::generate_hs_struct_writer(ofstream& out,
752                                                    t_struct* tstruct) {
753       string name = type_name(tstruct);
    CID 1232631:  Unused pointer value  (UNUSED_VALUE)
Pointer "fields" returned by "tstruct->get_sorted_members()" is never used.
754       const vector<t_field*>& fields = tstruct->get_sorted_members();
755       vector<t_field*>::const_iterator f_iter;
756       string str = tmp("_str");
757       string f = tmp("_f");
758       string v = tmp("_v");
759


________________________________________________________________________________________________________
To view the defects in Coverity Scan visit, http://scan.coverity.com/projects/1345?tab=overview


Reply via email to