Skip to content

Commit a59febc

Browse files
committed
add comments for setting errno=0
1 parent 37502f5 commit a59febc

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

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

Lines changed: 4 additions & 1 deletion
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,6 +2082,7 @@ 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;
2085+
// global variable, must set to 0 before using it to avoid changed by other errors
20842086
errno = 0;
20852087
out = std::strtoul(in, NULL, 10);
20862088
if(errno != 0)
@@ -2090,6 +2092,7 @@ 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;
2095+
// global variable, must set to 0 before using it to avoid changed by other errors
20932096
errno = 0;
20942097
out = std::strtof(in, NULL);
20952098
if(errno != 0)

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)