Skip to content

Commit 237dd87

Browse files
committed
try to fix invalid argument bug, set errno first before using it
1 parent 5ff5819 commit 237dd87

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

libs/librrgraph/src/io/gen/rr_graph_uxsdcxx.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2072,6 +2072,7 @@ inline enum_loc_side lex_enum_loc_side(const char *in, bool throw_on_invalid, co
20722072
/* Internal loading functions, which validate and load a PugiXML DOM tree into memory. */
20732073
inline int load_int(const char *in, const std::function<void(const char *)> * report_error){
20742074
int out;
2075+
errno = 0;
20752076
out = std::strtol(in, NULL, 10);
20762077
if(errno != 0)
20772078
noreturn_report(report_error, ("Invalid value `" + std::string(in) + "` when loading into a int.").c_str());
@@ -2080,6 +2081,7 @@ inline int load_int(const char *in, const std::function<void(const char *)> * re
20802081

20812082
inline unsigned int load_unsigned_int(const char *in, const std::function<void(const char *)> * report_error){
20822083
unsigned int out;
2084+
errno = 0;
20832085
out = std::strtoul(in, NULL, 10);
20842086
if(errno != 0)
20852087
noreturn_report(report_error, ("Invalid value `" + std::string(in) + "` when loading into a unsigned int.").c_str());
@@ -2088,6 +2090,7 @@ inline unsigned int load_unsigned_int(const char *in, const std::function<void(c
20882090

20892091
inline float load_float(const char *in, const std::function<void(const char *)> * report_error){
20902092
float out;
2093+
errno = 0;
20912094
out = std::strtof(in, NULL);
20922095
if(errno != 0)
20932096
noreturn_report(report_error, ("Invalid value `" + std::string(in) + "` when loading into a float.").c_str());

vpr/src/base/gen/vpr_constraints_uxsdcxx.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,7 @@ template<std::size_t N>
428428
inline int load_int(const char* in, const std::function<void(const char*)>* report_error) {
429429
int out;
430430
std::printf("before reading int errno:%d\n", errno);
431+
errno = 0;
431432
out = std::strtol(in, NULL, 10);
432433
if (errno != 0) {
433434
std::printf("after reading int errno:%d\n", errno);

vpr/src/base/vpr_constraints_serializer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class VprConstraintsSerializer final : public uxsd::VprConstraintsBase<VprConstr
115115
return temp_atom_string_.c_str();
116116
}
117117

118-
virtual inline void set_add_atom_name_pattern(const char* name_pattern, void*& ctx) final {
118+
virtual inline void set_add_atom_name_pattern(const char* name_pattern, void*& /*ctx*/) final {
119119
auto& atom_ctx = g_vpr_ctx.atom();
120120
std::string atom_name = name_pattern;
121121

0 commit comments

Comments
 (0)