Skip to content

Commit

Permalink
Fix format_mac_address function in parse_mac.cc
Browse files Browse the repository at this point in the history
Apparently the stream manipulator `std::setw` applies only to the next string written to the stream. Hence the function `format_mac_address` in parse_mac.cc only formatted the first pair of hexadecimal digits correctly. This went unnoticed until now because it only makes a difference for numbers below 0x10.
  • Loading branch information
antonott committed Aug 3, 2021
1 parent 6b5a8c1 commit ef5fd6c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/parse_mac.cc
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ class parse_mac_impl : public parse_mac
str << std::setfill('0') << std::hex << std::setw(2) << (int)addr[0];

for (int i = 1; i < 6; i++) {
str << ":" << (int)addr[i];
str << ":" << std::setw(2) << (int)addr[i];
}

return str.str();
Expand Down

0 comments on commit ef5fd6c

Please sign in to comment.