build: fix -Wunused-but-set-variable support and handle clang better

By default the build used -Wno-unused-but-set-variable but that's
clearly not what we want. Fix those problems.

When using clang, the compiler doesn't error on unknown compile
options, so let's add -Werror to the checking too.

CC='clang'
configure:3408: checking for gcc
configure:3435: result: clang
...
configure:17644: checking whether gcc understands -Wno-unused-but-set-variable
configure:17657: clang -c -Wall -std=gnu89 -g -O2 -Wmissing-declarations -Wmissing-prototypes -Wdeclaration-after-statement -Wstrict-prototypes -Wno-unused-parameter -Wno-sign-compare -Wno-deprecated-declarations -Wno-unused-but-set-variable  conftest.c >&5
warning: unknown warning option '-Wno-unused-but-set-variable'; did you mean '-Wno-unused-const-variable'? [-Wunknown-warning-option]
1 warning generated.
configure:17657: $? = 0
configure:17666: result: yes

Reported-by: Torsten Hilbrich <torsten.hilbrich@secunet.com>
This commit is contained in:
Dan Williams
2019-04-02 09:16:12 -05:00
parent 093174c84d
commit 88fac7f14a
5 changed files with 46 additions and 72 deletions

View File

@@ -11,9 +11,9 @@ if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then
-Wdeclaration-after-statement -Wstrict-prototypes \ -Wdeclaration-after-statement -Wstrict-prototypes \
-Wno-unused-parameter -Wno-sign-compare \ -Wno-unused-parameter -Wno-sign-compare \
-Wno-deprecated-declarations \ -Wno-deprecated-declarations \
-Wno-unused-but-set-variable -Wformat-security; do -Wunused-but-set-variable -Wformat-security; do
SAVE_CFLAGS="$CFLAGS" SAVE_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $option" CFLAGS="$CFLAGS $option -Werror"
AC_MSG_CHECKING([whether gcc understands $option]) AC_MSG_CHECKING([whether gcc understands $option])
AC_TRY_COMPILE([], [], AC_TRY_COMPILE([], [],
has_option=yes, has_option=yes,

View File

@@ -261,10 +261,8 @@ dial_cdma_ready (MMBaseModem *modem,
static void static void
cdma_connect_context_dial (GTask *task) cdma_connect_context_dial (GTask *task)
{ {
MMBroadbandBearer *self;
DetailedConnectContext *ctx; DetailedConnectContext *ctx;
self = g_task_get_source_object (task);
ctx = g_task_get_task_data (task); ctx = g_task_get_task_data (task);
mm_base_modem_at_command_full (ctx->modem, mm_base_modem_at_command_full (ctx->modem,

View File

@@ -238,14 +238,16 @@ modem_load_current_capabilities_finish (MMIfaceModem *self,
static void static void
complete_current_capabilities (GTask *task) complete_current_capabilities (GTask *task)
{ {
MMBroadbandModemMbim *self;
LoadCurrentCapabilitiesContext *ctx; LoadCurrentCapabilitiesContext *ctx;
MMModemCapability result = 0; MMModemCapability result = 0;
self = g_task_get_source_object (task);
ctx = g_task_get_task_data (task); ctx = g_task_get_task_data (task);
#if defined WITH_QMI && QMI_MBIM_QMUX_SUPPORTED #if defined WITH_QMI && QMI_MBIM_QMUX_SUPPORTED
{
MMBroadbandModemMbim *self;
self = g_task_get_source_object (task);
/* Warn if the MBIM loaded capabilities isn't a subset of the QMI loaded ones */ /* Warn if the MBIM loaded capabilities isn't a subset of the QMI loaded ones */
if (ctx->current_qmi && ctx->current_mbim) { if (ctx->current_qmi && ctx->current_mbim) {
gchar *mbim_caps_str; gchar *mbim_caps_str;
@@ -276,6 +278,7 @@ complete_current_capabilities (GTask *task)
* don't mix both logics */ * don't mix both logics */
if (self->priv->qmi_capability_and_mode_switching) if (self->priv->qmi_capability_and_mode_switching)
mm_info ("QMI-based capability and mode switching support enabled"); mm_info ("QMI-based capability and mode switching support enabled");
}
#else #else
result = ctx->current_mbim; result = ctx->current_mbim;
#endif #endif
@@ -1967,9 +1970,7 @@ static void
allocate_next_qmi_client (GTask *task) allocate_next_qmi_client (GTask *task)
{ {
InitializationStartedContext *ctx; InitializationStartedContext *ctx;
MMBroadbandModemMbim *self;
self = g_task_get_source_object (task);
ctx = g_task_get_task_data (task); ctx = g_task_get_task_data (task);
if (ctx->qmi_service_index == G_N_ELEMENTS (qmi_services)) { if (ctx->qmi_service_index == G_N_ELEMENTS (qmi_services)) {
@@ -2608,12 +2609,9 @@ set_lte_attach_configuration_set_ready (MbimDevice *device,
GAsyncResult *res, GAsyncResult *res,
GTask *task) GTask *task)
{ {
MMBroadbandModemMbim *self;
MbimMessage *response; MbimMessage *response;
GError *error = NULL; GError *error = NULL;
self = g_task_get_source_object (task);
response = mbim_device_command_finish (device, res, &error); response = mbim_device_command_finish (device, res, &error);
if (!response || !mbim_message_response_get_result (response, MBIM_MESSAGE_TYPE_COMMAND_DONE, &error)) if (!response || !mbim_message_response_get_result (response, MBIM_MESSAGE_TYPE_COMMAND_DONE, &error))
g_task_return_error (task, error); g_task_return_error (task, error);
@@ -2630,7 +2628,6 @@ before_set_lte_attach_configuration_query_ready (MbimDevice *device,
GAsyncResult *res, GAsyncResult *res,
GTask *task) GTask *task)
{ {
MMBroadbandModemMbim *self;
MbimMessage *request; MbimMessage *request;
MbimMessage *response; MbimMessage *response;
GError *error = NULL; GError *error = NULL;
@@ -2639,7 +2636,6 @@ before_set_lte_attach_configuration_query_ready (MbimDevice *device,
MbimLteAttachConfiguration **configurations = NULL; MbimLteAttachConfiguration **configurations = NULL;
guint i; guint i;
self = g_task_get_source_object (task);
config = g_task_get_task_data (task); config = g_task_get_task_data (task);
response = mbim_device_command_finish (device, res, &error); response = mbim_device_command_finish (device, res, &error);

View File

@@ -1676,29 +1676,29 @@ MMPortType
mm_port_probe_get_port_type (MMPortProbe *self) mm_port_probe_get_port_type (MMPortProbe *self)
{ {
const gchar *subsys; const gchar *subsys;
const gchar *name;
g_return_val_if_fail (MM_IS_PORT_PROBE (self), FALSE); g_return_val_if_fail (MM_IS_PORT_PROBE (self), FALSE);
subsys = mm_kernel_device_get_subsystem (self->priv->port); subsys = mm_kernel_device_get_subsystem (self->priv->port);
name = mm_kernel_device_get_name (self->priv->port);
if (g_str_equal (subsys, "net")) if (g_str_equal (subsys, "net"))
return MM_PORT_TYPE_NET; return MM_PORT_TYPE_NET;
if (g_str_has_prefix (subsys, "usb")) {
const gchar *name;
name = mm_kernel_device_get_name (self->priv->port);
if (g_str_has_prefix (name, "cdc-wdm")) {
#if defined WITH_QMI #if defined WITH_QMI
if (g_str_has_prefix (subsys, "usb") && if (self->priv->is_qmi)
g_str_has_prefix (name, "cdc-wdm") &&
self->priv->is_qmi)
return MM_PORT_TYPE_QMI; return MM_PORT_TYPE_QMI;
#endif #endif
#if defined WITH_MBIM #if defined WITH_MBIM
if (g_str_has_prefix (subsys, "usb") && if (self->priv->is_mbim)
g_str_has_prefix (name, "cdc-wdm") &&
self->priv->is_mbim)
return MM_PORT_TYPE_MBIM; return MM_PORT_TYPE_MBIM;
#endif #endif
}
}
if (self->priv->flags & MM_PORT_PROBE_QCDM && if (self->priv->flags & MM_PORT_PROBE_QCDM &&
self->priv->is_qcdm) self->priv->is_qcdm)

View File

@@ -398,14 +398,10 @@ out:
static void static void
set_current_capabilities_system_selection_preference (GTask *task) set_current_capabilities_system_selection_preference (GTask *task)
{ {
MMSharedQmi *self;
Private *priv;
SetCurrentCapabilitiesContext *ctx; SetCurrentCapabilitiesContext *ctx;
QmiMessageNasSetSystemSelectionPreferenceInput *input; QmiMessageNasSetSystemSelectionPreferenceInput *input;
QmiNasRatModePreference pref; QmiNasRatModePreference pref;
self = g_task_get_source_object (task);
priv = get_private (MM_SHARED_QMI (self));
ctx = g_task_get_task_data (task); ctx = g_task_get_task_data (task);
pref = mm_modem_capability_to_qmi_rat_mode_preference (ctx->capabilities); pref = mm_modem_capability_to_qmi_rat_mode_preference (ctx->capabilities);
@@ -919,12 +915,9 @@ set_current_modes_technology_preference_ready (QmiClientNas *client,
GAsyncResult *res, GAsyncResult *res,
GTask *task) GTask *task)
{ {
SetCurrentModesContext *ctx;
QmiMessageNasSetTechnologyPreferenceOutput *output = NULL; QmiMessageNasSetTechnologyPreferenceOutput *output = NULL;
GError *error = NULL; GError *error = NULL;
ctx = g_task_get_task_data (task);
output = qmi_client_nas_set_technology_preference_finish (client, res, &error); output = qmi_client_nas_set_technology_preference_finish (client, res, &error);
if (!output || if (!output ||
(!qmi_message_nas_set_technology_preference_output_get_result (output, &error) && (!qmi_message_nas_set_technology_preference_output_get_result (output, &error) &&
@@ -993,12 +986,9 @@ set_current_modes_system_selection_preference_ready (QmiClientNas *client,
GAsyncResult *res, GAsyncResult *res,
GTask *task) GTask *task)
{ {
SetCurrentModesContext *ctx;
QmiMessageNasSetSystemSelectionPreferenceOutput *output = NULL; QmiMessageNasSetSystemSelectionPreferenceOutput *output = NULL;
GError *error = NULL; GError *error = NULL;
ctx = g_task_get_task_data (task);
output = qmi_client_nas_set_system_selection_preference_finish (client, res, &error); output = qmi_client_nas_set_system_selection_preference_finish (client, res, &error);
if (!output || !qmi_message_nas_set_system_selection_preference_output_get_result (output, &error)) if (!output || !qmi_message_nas_set_system_selection_preference_output_get_result (output, &error))
g_task_return_error (task, error); g_task_return_error (task, error);
@@ -1016,11 +1006,9 @@ set_current_modes_system_selection_preference (GTask *task)
MMIfaceModem *self; MMIfaceModem *self;
SetCurrentModesContext *ctx; SetCurrentModesContext *ctx;
QmiMessageNasSetSystemSelectionPreferenceInput *input; QmiMessageNasSetSystemSelectionPreferenceInput *input;
Private *priv;
QmiNasRatModePreference pref; QmiNasRatModePreference pref;
self = g_task_get_source_object (task); self = g_task_get_source_object (task);
priv = get_private (MM_SHARED_QMI (self));
ctx = g_task_get_task_data (task); ctx = g_task_get_task_data (task);
input = qmi_message_nas_set_system_selection_preference_input_new (); input = qmi_message_nas_set_system_selection_preference_input_new ();
@@ -1162,15 +1150,12 @@ get_technology_preference_ready (QmiClientNas *client,
GAsyncResult *res, GAsyncResult *res,
GTask *task) GTask *task)
{ {
LoadCurrentModesContext *ctx;
LoadCurrentModesResult *result = NULL; LoadCurrentModesResult *result = NULL;
QmiMessageNasGetTechnologyPreferenceOutput *output = NULL; QmiMessageNasGetTechnologyPreferenceOutput *output = NULL;
GError *error = NULL; GError *error = NULL;
MMModemMode allowed; MMModemMode allowed;
QmiNasRadioTechnologyPreference preference_mask; QmiNasRadioTechnologyPreference preference_mask;
ctx = g_task_get_task_data (task);
output = qmi_client_nas_get_technology_preference_finish (client, res, &error); output = qmi_client_nas_get_technology_preference_finish (client, res, &error);
if (!output || !qmi_message_nas_get_technology_preference_output_get_result (output, &error)) { if (!output || !qmi_message_nas_get_technology_preference_output_get_result (output, &error)) {
g_task_return_error (task, error); g_task_return_error (task, error);
@@ -1226,15 +1211,12 @@ load_current_modes_system_selection_preference_ready (QmiClientNas *client,
GAsyncResult *res, GAsyncResult *res,
GTask *task) GTask *task)
{ {
LoadCurrentModesContext *ctx;
LoadCurrentModesResult *result = NULL; LoadCurrentModesResult *result = NULL;
QmiMessageNasGetSystemSelectionPreferenceOutput *output = NULL; QmiMessageNasGetSystemSelectionPreferenceOutput *output = NULL;
GError *error = NULL; GError *error = NULL;
QmiNasRatModePreference mode_preference_mask = 0; QmiNasRatModePreference mode_preference_mask = 0;
MMModemMode allowed; MMModemMode allowed;
ctx = g_task_get_task_data (task);
output = qmi_client_nas_get_system_selection_preference_finish (client, res, &error); output = qmi_client_nas_get_system_selection_preference_finish (client, res, &error);
if (!output || !qmi_message_nas_get_system_selection_preference_output_get_result (output, &error)) { if (!output || !qmi_message_nas_get_system_selection_preference_output_get_result (output, &error)) {
g_task_return_error (task, error); g_task_return_error (task, error);
@@ -4068,7 +4050,6 @@ pds_get_default_tracking_session_ready (QmiClientPds *client,
GAsyncResult *res, GAsyncResult *res,
GTask *task) GTask *task)
{ {
MMSharedQmi *self;
SetGpsOperationModeContext *ctx; SetGpsOperationModeContext *ctx;
QmiMessagePdsSetDefaultTrackingSessionInput *input; QmiMessagePdsSetDefaultTrackingSessionInput *input;
QmiMessagePdsGetDefaultTrackingSessionOutput *output; QmiMessagePdsGetDefaultTrackingSessionOutput *output;
@@ -4094,7 +4075,6 @@ pds_get_default_tracking_session_ready (QmiClientPds *client,
return; return;
} }
self = g_task_get_source_object (task);
ctx = g_task_get_task_data (task); ctx = g_task_get_task_data (task);
qmi_message_pds_get_default_tracking_session_output_get_info ( qmi_message_pds_get_default_tracking_session_output_get_info (