platform: refactor wifi_utils_is_wifi() not to pass sysfs_path
wifi_utils_is_wifi() only has one caller, so it's very clear what the passed in @sysfs_path contains. Instead of accepting a redundant argument, compute the sysfs path internally based on @iface alone.
This commit is contained in:
@@ -736,7 +736,7 @@ _linktype_get_type (NMPlatform *platform,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Fallback for drivers that don't call SET_NETDEV_DEVTYPE() */
|
/* Fallback for drivers that don't call SET_NETDEV_DEVTYPE() */
|
||||||
if (wifi_utils_is_wifi (ifname, sysfs_path))
|
if (wifi_utils_is_wifi (ifname))
|
||||||
return NM_LINK_TYPE_WIFI;
|
return NM_LINK_TYPE_WIFI;
|
||||||
|
|
||||||
if (arptype == ARPHRD_ETHER) {
|
if (arptype == ARPHRD_ETHER) {
|
||||||
|
@@ -21,16 +21,18 @@
|
|||||||
|
|
||||||
#include "nm-default.h"
|
#include "nm-default.h"
|
||||||
|
|
||||||
|
#include "wifi-utils.h"
|
||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "wifi-utils.h"
|
|
||||||
#include "wifi-utils-private.h"
|
#include "wifi-utils-private.h"
|
||||||
#include "wifi-utils-nl80211.h"
|
#include "wifi-utils-nl80211.h"
|
||||||
#if HAVE_WEXT
|
#if HAVE_WEXT
|
||||||
#include "wifi-utils-wext.h"
|
#include "wifi-utils-wext.h"
|
||||||
#endif
|
#endif
|
||||||
|
#include "nm-core-utils.h"
|
||||||
|
|
||||||
gpointer
|
gpointer
|
||||||
wifi_data_new (const char *iface, int ifindex, gsize len)
|
wifi_data_new (const char *iface, int ifindex, gsize len)
|
||||||
@@ -162,19 +164,20 @@ wifi_utils_deinit (WifiData *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
wifi_utils_is_wifi (const char *iface, const char *sysfs_path)
|
wifi_utils_is_wifi (const char *iface)
|
||||||
{
|
{
|
||||||
char phy80211_path[255];
|
char phy80211_path[NM_STRLEN ("/sys/class/net/123456789012345/phy80211\0") + 100 /*safety*/];
|
||||||
struct stat s;
|
struct stat s;
|
||||||
|
|
||||||
g_return_val_if_fail (iface != NULL, FALSE);
|
g_return_val_if_fail (iface != NULL, FALSE);
|
||||||
|
|
||||||
if (sysfs_path) {
|
nm_sprintf_buf (phy80211_path,
|
||||||
/* Check for nl80211 sysfs paths */
|
"/sys/class/net/%s/phy80211",
|
||||||
g_snprintf (phy80211_path, sizeof (phy80211_path), "%s/phy80211", sysfs_path);
|
NM_ASSERT_VALID_PATH_COMPONENT (iface));
|
||||||
|
nm_assert (strlen (phy80211_path) < sizeof (phy80211_path) - 1);
|
||||||
|
|
||||||
if ((stat (phy80211_path, &s) == 0 && (s.st_mode & S_IFDIR)))
|
if ((stat (phy80211_path, &s) == 0 && (s.st_mode & S_IFDIR)))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
|
||||||
|
|
||||||
#if HAVE_WEXT
|
#if HAVE_WEXT
|
||||||
if (wifi_wext_is_wifi (iface))
|
if (wifi_wext_is_wifi (iface))
|
||||||
|
@@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
typedef struct WifiData WifiData;
|
typedef struct WifiData WifiData;
|
||||||
|
|
||||||
gboolean wifi_utils_is_wifi (const char *iface, const char *sysfs_path);
|
gboolean wifi_utils_is_wifi (const char *iface);
|
||||||
|
|
||||||
WifiData *wifi_utils_init (const char *iface, int ifindex, gboolean check_scan);
|
WifiData *wifi_utils_init (const char *iface, int ifindex, gboolean check_scan);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user