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 22:37:19 -0500 [thread overview]
Message-ID: <b91ce547-a36b-91fa-6dfe-1326cca020ca@gmail.com> (raw)
In-Reply-To: <CAKSBH7FuMX2xdZ0oNgKDzOz8WZQEp7g-9DBy8Utb-oFzWPVbBA@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1419 bytes --]
Hi Giacinto,
> this is in a function that assigns the variable for sure:
>
> static uint32_t auth_method_to_auth_protocol(enum ofono_gprs_auth_method method)
> {
> switch (method) {
> case OFONO_GPRS_AUTH_METHOD_CHAP:
> return 2; /* MBIMAuthProtocolChap */
> case OFONO_GPRS_AUTH_METHOD_PAP:
> return 1; /* MBIMAuthProtocolPap */
> }
>
> return 0; // < see here?
> }
>
> that's why the compiler doesnt complain.
>
Sure, but you also know the core will never send you a value that is not
PAP/CHAP. So you know that in reality we never get to the 'return 0'
part, even though the compiler might think that we could.
And if we ever add a new enumeration and forget to update this code, the
compiler will complain. This is what we want. If we add a default:
here, compiler will not warn us, that leads to bugs.
>> uint32_t auth;
>>
>> if (auth_method_to_foo(method, &auth) < 0)
>> goto error;
>>
>
> this doesnt work, because it could leave the variable auth unassigned,
> according to the compiler.
Not according to any compiler I tried. I literally tested this before
sending the above email on both GCC 7.3 and GCC 8.2. So what compiler
are you using?
>
> Please note that the current code for qmimodem has a default already,
> and it is the only way the compiler doesn't complain:
And that is wrong and should be fixed.
Regards,
-Denis
next prev parent reply other threads:[~2018-10-05 3:37 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
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 [this message]
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=b91ce547-a36b-91fa-6dfe-1326cca020ca@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