Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NM plugin fixes #13

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 28 additions & 17 deletions nm/src/nm.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ typedef struct {
} J4statusNmSection;

static GVariant *
_j4status_nm_format_up_eth_callback(const gchar *token, guint64 value, gconstpointer user_data)
_j4status_nm_format_up_eth_callback(G_GNUC_UNUSED const gchar *token, guint64 value, gconstpointer user_data)
{
const J4statusNmFormatUpEthData *data = user_data;
switch ( value )
Expand All @@ -196,7 +196,7 @@ _j4status_nm_format_up_eth_callback(const gchar *token, guint64 value, gconstpoi
}

static GVariant *
_j4status_nm_format_up_wifi_callback(const gchar *token, guint64 value, gconstpointer user_data)
_j4status_nm_format_up_wifi_callback(G_GNUC_UNUSED const gchar *token, guint64 value, gconstpointer user_data)
{
const J4statusNmFormatUpWiFiData *data = user_data;
switch ( value )
Expand All @@ -220,7 +220,7 @@ _j4status_nm_format_up_wifi_callback(const gchar *token, guint64 value, gconstpo
}

static GVariant *
_j4status_nm_format_down_wifi_callback(const gchar *token, guint64 value, gconstpointer user_data)
_j4status_nm_format_down_wifi_callback(G_GNUC_UNUSED const gchar *token, guint64 value, gconstpointer user_data)
{
const gint64 *aps_number = user_data;
switch ( value )
Expand All @@ -237,7 +237,7 @@ _j4status_nm_format_down_wifi_callback(const gchar *token, guint64 value, gconst
}

static GVariant *
_j4status_nm_format_up_other_callback(const gchar *token, guint64 value, gconstpointer user_data)
_j4status_nm_format_up_other_callback(G_GNUC_UNUSED const gchar *token, guint64 value, gconstpointer user_data)
{
switch ( value )
{
Expand All @@ -253,13 +253,15 @@ _j4status_nm_format_up_other_callback(const gchar *token, guint64 value, gconstp
}

static GVariant *
_j4status_nm_format_down_other_callback(const gchar *token, guint64 value, gconstpointer user_data)
_j4status_nm_format_down_other_callback(G_GNUC_UNUSED const gchar *token,
G_GNUC_UNUSED guint64 value,
G_GNUC_UNUSED gconstpointer user_data)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: style, all on the same line

{
return NULL;
}

static void
_j4status_nm_device_get_addresses_ipv4(J4statusPluginContext *context, NMDevice *device, GVariantBuilder *builder)
_j4status_nm_device_get_addresses_ipv4(G_GNUC_UNUSED J4statusPluginContext *context, NMDevice *device, GVariantBuilder *builder)
{
NMIPConfig *ip4_config;

Expand All @@ -277,7 +279,7 @@ _j4status_nm_device_get_addresses_ipv4(J4statusPluginContext *context, NMDevice
}

static void
_j4status_nm_device_get_addresses_ipv6(J4statusPluginContext *context, NMDevice *device, GVariantBuilder *builder)
_j4status_nm_device_get_addresses_ipv6(G_GNUC_UNUSED J4statusPluginContext *context, NMDevice *device, GVariantBuilder *builder)
{
NMIPConfig *ip6_config;

Expand Down Expand Up @@ -403,18 +405,23 @@ _j4status_nm_device_update(J4statusPluginContext *context, J4statusNmSection *se

if ( context->formats.up_wifi_tokens & TOKEN_FLAG_UP_WIFI_SSID )
{
const GByteArray *raw_ssid;
raw_ssid = nm_access_point_get_ssid(section->ap);
data.ssid = g_variant_new_take_string(g_strndup((const gchar *)raw_ssid->data, raw_ssid->len));
GBytes *raw_ssid = nm_access_point_get_ssid(section->ap);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hum, that’s new from the libnm merge, so you need to say that in the commit message.

if (raw_ssid) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition must be in the previous commit as it’s the one introducing the NULL case.

Nit: also 3 style issues here: spaces around parens, != NULL and bracket on the following line

char *active_ssid_str = nm_utils_ssid_to_utf8(g_bytes_get_data (raw_ssid, NULL),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: gchar, and you can just call it ssid or just put the function call in g_variant_new_take_string()

g_bytes_get_size (raw_ssid));
data.ssid = g_variant_new_take_string(active_ssid_str);
}
}
}

data.bitrate = nm_device_wifi_get_bitrate(NM_DEVICE_WIFI(device)) * 1000;

value = j4status_format_string_replace(context->formats.up_wifi, _j4status_nm_format_up_wifi_callback, &data);

if ( data.ssid != NULL )
if ( data.ssid != NULL ) {
g_variant_unref(data.ssid);
data.ssid = NULL;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data is a local variable and will not survive the case block so there is no need to set it to NULL.
Did you hit any issue here? If so, it’s a good thing to say it in the commit message and explain why.
It would definitely need its own commit if you really need that.

if ( data.addresses != NULL )
g_variant_unref(data.addresses);
}
Expand Down Expand Up @@ -468,7 +475,8 @@ _j4status_nm_device_update(J4statusPluginContext *context, J4statusNmSection *se
}

static void
_j4status_nm_access_point_property_changed(NMAccessPoint *device, GParamSpec *pspec, gpointer user_data)
_j4status_nm_access_point_property_changed(G_GNUC_UNUSED NMAccessPoint *device,
G_GNUC_UNUSED GParamSpec *pspec, gpointer user_data)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: style

{
J4statusNmSection *section = user_data;
_j4status_nm_device_update(section->context, section, section->device);
Expand All @@ -493,14 +501,17 @@ _j4status_nm_device_property_changed(NMDevice *device, GParamSpec *pspec, gpoint
}

static void
_j4status_nm_device_state_changed(NMDevice *device, guint state, guint arg2, guint arg3, gpointer user_data)
_j4status_nm_device_state_changed(NMDevice *device,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: style

G_GNUC_UNUSED guint state,
G_GNUC_UNUSED guint arg2,
G_GNUC_UNUSED guint arg3, gpointer user_data)
{
J4statusNmSection *section = user_data;
_j4status_nm_device_update(section->context, section, device);
}

static void
_j4status_nm_device_monitor(gpointer key, gpointer data, gpointer user_data)
_j4status_nm_device_monitor(G_GNUC_UNUSED gpointer key, gpointer data, G_GNUC_UNUSED gpointer user_data)
{
J4statusNmSection *section = data;

Expand All @@ -523,7 +534,7 @@ _j4status_nm_device_monitor(gpointer key, gpointer data, gpointer user_data)
}

static void
_j4status_nm_device_unmonitor(gpointer key, gpointer data, gpointer user_data)
_j4status_nm_device_unmonitor(G_GNUC_UNUSED gpointer key, gpointer data, G_GNUC_UNUSED gpointer user_data)
{
J4statusNmSection *section = data;

Expand Down Expand Up @@ -635,7 +646,7 @@ _j4status_nm_section_detach_device(J4statusNmSection *section)
}

static void
_j4status_nm_client_device_added(NMClient *client, NMDevice *device, gpointer user_data)
_j4status_nm_client_device_added(G_GNUC_UNUSED NMClient *client, NMDevice *device, gpointer user_data)
{
J4statusPluginContext *context = user_data;
J4statusNmSection *section;
Expand All @@ -645,7 +656,7 @@ _j4status_nm_client_device_added(NMClient *client, NMDevice *device, gpointer us
}

static void
_j4status_nm_client_device_removed(NMClient *client, NMDevice *device, gpointer user_data)
_j4status_nm_client_device_removed(G_GNUC_UNUSED NMClient *client, NMDevice *device, gpointer user_data)
{
J4statusPluginContext *context = user_data;
J4statusNmSection *section;
Expand Down