Skip to content

Commit 02252c8

Browse files
authored
Merge pull request #2194 from verilog-to-routing/errno-comment
add comments for setting errno=0
2 parents 37502f5 + 42152d0 commit 02252c8

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2072,7 +2072,8 @@ 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;
2075+
// global variable, must set to 0 before using it to avoid changed by other errors
2076+
errno = 0;
20762077
out = std::strtol(in, NULL, 10);
20772078
if(errno != 0)
20782079
noreturn_report(report_error, ("Invalid value `" + std::string(in) + "` when loading into a int.").c_str());
@@ -2081,7 +2082,8 @@ inline int load_int(const char *in, const std::function<void(const char *)> * re
20812082

20822083
inline unsigned int load_unsigned_int(const char *in, const std::function<void(const char *)> * report_error){
20832084
unsigned int out;
2084-
errno = 0;
2085+
// global variable, must set to 0 before using it to avoid changed by other errors
2086+
errno = 0;
20852087
out = std::strtoul(in, NULL, 10);
20862088
if(errno != 0)
20872089
noreturn_report(report_error, ("Invalid value `" + std::string(in) + "` when loading into a unsigned int.").c_str());
@@ -2090,7 +2092,8 @@ inline unsigned int load_unsigned_int(const char *in, const std::function<void(c
20902092

20912093
inline float load_float(const char *in, const std::function<void(const char *)> * report_error){
20922094
float out;
2093-
errno = 0;
2095+
// global variable, must set to 0 before using it to avoid changed by other errors
2096+
errno = 0;
20942097
out = std::strtof(in, NULL);
20952098
if(errno != 0)
20962099
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
@@ -427,6 +427,7 @@ template<std::size_t N>
427427
/* Internal loading functions, which validate and load a PugiXML DOM tree into memory. */
428428
inline int load_int(const char* in, const std::function<void(const char*)>* report_error) {
429429
int out;
430+
// global variable, must set to 0 before using it to avoid changed by other errors
430431
errno = 0;
431432
out = std::strtol(in, NULL, 10);
432433
if (errno != 0)

0 commit comments

Comments
 (0)