From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH 6/6] drivers: support for auth NONE
Date: Thu, 04 Oct 2018 21:20:13 -0500 [thread overview]
Message-ID: <161f6b03-24dd-e00b-ea11-0e361dbb3d73@gmail.com> (raw)
In-Reply-To: <CAKSBH7HM2+-=8dqqNy3yahcTKTXT4LYnefvoiCp04O08YpYMWw@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2285 bytes --]
Hi Giacinto,
>> Ugh. I really hate GCC people sometimes. While the warning is strictly
>> correct, it is useless for 99% of the code and forces us to jump through
>> hoops. Anyway, I would propose we use the following pattern:
>>
>> int auth_method_to_qmi(enum ofono_auth_method method, uint8_t *out_auth)
>> {
>> switch (method)
>> case CHAP:
>> *out_auth = ...
>> return 0;
>> case:
>> ...
>> }
>>
>> return -ERANGE;
>> }
>>
>
> I tried but it is worst. Now gcc complains about potentially
> uninitialized variable.
>
> Here is the code
> static int auth_method_to_qmi(enum ofono_gprs_auth_method method,
> uint8_t *out_auth)
> {
> switch (method) {
> case OFONO_GPRS_AUTH_METHOD_CHAP:
> *out_auth = QMI_WDS_AUTHENTICATION_CHAP;
> return 0;
> case OFONO_GPRS_AUTH_METHOD_PAP:
> *out_auth = QMI_WDS_AUTHENTICATION_PAP;
> return 0;
> case OFONO_GPRS_AUTH_METHOD_NONE:
> *out_auth = QMI_WDS_AUTHENTICATION_NONE;
> return 0;
> }
> return -1;
> }
>
> static void qmi_activate_primary(struct ofono_gprs_context *gc,
> [...]
> uint8_t auth;
> [...]
> auth_method_to_qmi(ctx->auth_method, &auth);
Well you might want to check for an error return here. e.g.
if (auth_method_to_qmi() < 0) {
CALLBACK_WITH_FAILURE();
return;
}
>
> and here the compiler answer:
>
> drivers/qmimodem/gprs-context.c:288:2: error: ‘auth’ may be used
> uninitialized in this function [-Werror=maybe-uninitialized]
> qmi_param_append_uint8(param, QMI_WDS_PARAM_AUTHENTICATION_PREFERENCE,
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> auth);
> ~~~~~
>
> It doesn't look like we have a clean way out of this. I can
> pre-initialize the variable, add a default to the switch, return the
> value for uint8 out_auth,
> but none of these will give you a clean solution.
No, we should not initialize variables unnecessarily. This is even
documented: doc/coding-style.txt, item M7
>
> I prefer therefore to keep it as it is, with a comment about why it is done so.
>
I prefer we set a good example :)
Regards,
-Denis
next prev parent reply other threads:[~2018-10-05 2:20 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-02 6:26 [PATCH 1/6] connman-api: added "none" auth_method Giacinto Cifelli
2018-10-02 6:26 ` [PATCH 2/6] gprs-context: added OFONO_GPRS_AUTH_METHOD_NONE Giacinto Cifelli
2018-10-02 6:26 ` [PATCH 4/6] plugins/file-provisioning.c: support for auth NONE Giacinto Cifelli
2018-10-02 6:26 ` [PATCH 3/6] src/gprs: support for NONE auth Giacinto Cifelli
2018-10-02 6:26 ` [PATCH 5/6] gatchat: support for auth NONE Giacinto Cifelli
2018-10-02 23:26 ` Denis Kenzior
2018-10-02 6:26 ` [PATCH 6/6] drivers: " Giacinto Cifelli
2018-10-03 21:29 ` Denis Kenzior
2018-10-04 3:44 ` Giacinto Cifelli
2018-10-04 4:40 ` Denis Kenzior
2018-10-04 4:51 ` Giacinto Cifelli
2018-10-05 2:04 ` Denis Kenzior
2018-10-05 2:07 ` Giacinto Cifelli
2018-10-04 4:43 ` Giacinto Cifelli
2018-10-05 2:20 ` Denis Kenzior [this message]
2018-10-05 2:23 ` Giacinto Cifelli
2018-10-05 2:47 ` Denis Kenzior
2018-10-05 2:51 ` Giacinto Cifelli
2018-10-05 3:23 ` Denis Kenzior
2018-10-05 3:30 ` Giacinto Cifelli
2018-10-05 3:37 ` Denis Kenzior
2018-10-05 3:54 ` Giacinto Cifelli
2018-10-05 4:09 ` Denis Kenzior
2018-10-05 4:13 ` Giacinto Cifelli
-- strict thread matches above, loose matches on Subject: below --
2018-10-04 5:05 [PATCH 4/6] plugins/provisioning and mbpi: " Giacinto Cifelli
2018-10-04 5:05 ` [PATCH 6/6] drivers: " Giacinto Cifelli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=161f6b03-24dd-e00b-ea11-0e361dbb3d73@gmail.com \
--to=denkenz@gmail.com \
--cc=ofono@ofono.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox