Skip to content

Commit

Permalink
COMMON/HELPERS/GTEST: convert stack allocation at netif_has_sysfs_fil…
Browse files Browse the repository at this point in the history
…e() to heap
  • Loading branch information
michal-shalev committed Sep 16, 2024
1 parent 4c86c1a commit 3eed8b6
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions test/gtest/common/test_helpers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -456,12 +456,13 @@ bool is_inet_addr(const struct sockaddr* ifa_addr) {

static bool netif_has_sysfs_file(const char *ifa_name, const char *file_name)
{
char path[PATH_MAX];
ucs_snprintf_safe(path, sizeof(path), "/sys/class/net/%s/%s", ifa_name,
file_name);
std::string path(PATH_MAX, '\0');

ucs_snprintf_safe(&path[0], path.size(), "/sys/class/net/%s/%s",
ifa_name, file_name);

struct stat st;
return stat(path, &st) >= 0;
return stat(path.c_str(), &st) >= 0;
}

bool is_interface_usable(struct ifaddrs *ifa)
Expand Down

0 comments on commit 3eed8b6

Please sign in to comment.