Fixed use of char array for string in blifparse error handling
authorClifford Wolf <clifford@clifford.at>
Wed, 8 Aug 2018 17:41:47 +0000 (19:41 +0200)
committerClifford Wolf <clifford@clifford.at>
Wed, 8 Aug 2018 17:41:47 +0000 (19:41 +0200)
Signed-off-by: Clifford Wolf <clifford@clifford.at>
frontends/blif/blifparse.cc

index b81808b1e56c036a40a27b343f4acc1df9e3bf5a..26cd14033607353339a5379727f95f5602d30cbf 100644 (file)
@@ -85,7 +85,7 @@ void parse_blif(RTLIL::Design *design, std::istream &f, std::string dff_name, bo
        RTLIL::Cell *sopcell = NULL;
        RTLIL::Cell *lastcell = nullptr;
        RTLIL::State lut_default_state = RTLIL::State::Sx;
-       char err_reason[80];
+       std::string err_reason;
        int blif_maxnum = 0, sopmode = -1;
 
        auto blif_wire = [&](const std::string &wire_name) -> Wire*
@@ -276,7 +276,7 @@ void parse_blif(RTLIL::Design *design, std::istream &f, std::string dff_name, bo
 
                                if(lastcell == nullptr || module == nullptr)
                                {
-                                       snprintf(err_reason, sizeof(err_reason), "No primative object to attach .cname %s.", p);
+                                       err_reason = stringf("No primative object to attach .cname %s.", p);
                                        goto error_with_reason;
                                }
 
@@ -302,13 +302,13 @@ void parse_blif(RTLIL::Design *design, std::istream &f, std::string dff_name, bo
                                }
                                if (!strcmp(cmd, ".attr")) {
                                        if (obj_attributes == nullptr) {
-                                               snprintf(err_reason, sizeof(err_reason), "No object to attach .attr too.");
+                                               err_reason = stringf("No object to attach .attr too.");
                                                goto error_with_reason;
                                        }
                                        (*obj_attributes)[id_n] = const_v;
                                } else {
                                        if (obj_parameters == nullptr) {
-                                               snprintf(err_reason, sizeof(err_reason), "No object to attach .param too.");
+                                               err_reason = stringf("No object to attach .param too.");
                                                goto error_with_reason;
                                        }
                                        (*obj_parameters)[id_n] = const_v;
@@ -575,7 +575,7 @@ void parse_blif(RTLIL::Design *design, std::istream &f, std::string dff_name, bo
 error:
        log_error("Syntax error in line %d!\n", line_count);
 error_with_reason:
-       log_error("Syntax error in line %d: %s\n", line_count, err_reason);
+       log_error("Syntax error in line %d: %s\n", line_count, err_reason.c_str());
 }
 
 struct BlifFrontend : public Frontend {