Open Source Telephony
 help / color / mirror / Atom feed
From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH v2 1/2] stkutil: Complete the TLV parsing/builder to support BIP commands
Date: Thu, 31 Mar 2011 10:37:47 -0500	[thread overview]
Message-ID: <4D949FCB.9080908@gmail.com> (raw)
In-Reply-To: <4D94596B.8070008@linux.intel.com>

[-- Attachment #1: Type: text/plain, Size: 2010 bytes --]

Hi Philippe,

>>> +        }
>>> +    }
>>> +
>>> +    *apn = g_try_malloc(offset + 1);
>>> +    if (*apn == NULL)
>>> +        return FALSE;
>>> +
>>> +    memcpy(*apn, decoded_apn, offset);
>>> +    (*apn)[offset] = '\0';
>>
>> *apn = g_strdup(decoded_apn);
>>
>> is really just fine ;)
>>
>>>
> 
> Ok, I'm just going to use g_strndup to get the string null terminated.
> 
> 

Might be easier to null terminate decoded_apn and use g_strdup.  That
might be a bit easier to read (and a more common variation) then trying
to use g_strndup.

>>> +/* Defined in TS 102.223 Section 8.56 */
>>> +enum stk_channel_status {
>>> +    STK_CHANNEL_PACKET_DATA_SERVICE_NOT_ACTIVATED = 0x00,
>>> +    STK_CHANNEL_PACKET_DATA_SERVICE_ACTIVATED =    0x01,
>>> +    STK_CHANNEL_TCP_IN_CLOSED_STATE =        0x02,
>>> +    STK_CHANNEL_TCP_IN_LISTEN_STATE =        0x03,
>>> +    STK_CHANNEL_TCP_IN_ESTABLISHED_STATE =        0x04,
>>> +    STK_CHANNEL_LINK_DROPPED =            0x05,
>>> +};
>>> +
>>
>> You're playing serious magic here, but fair enough.
> 
> 
> Here, I'm introducing these enums to list only the different channel
> status but they can't be used indeed as direct values for the channel
> status TLV parsing/building.
> 
> Note that for the section:
> 
> enum stk_qualifier_open_channel {
>     STK_OPEN_CHANNEL_ON_DEMAND =            0x00,
>     STK_OPEN_CHANNEL_IMMEDIATE =            0x01,
>     STK_OPEN_CHANNEL_AUTOMATIC_RECONNECTION =    0x02,
>     STK_OPEN_CHANNEL_IMMEDIATE_IN_BACKGROUND_MODE =    0x04,
> };
> 
> The purpose of these enums is to use them as bit masks. Maybe #defines
> could be more appropriate?

I'd almost suggest booleans or 3 separate enums instead.  However, it is
fine to use enums in such a manner (though I don't see the point of 0x00
value).  It might be better to indicate they're flags / bits in the enum
name.  e.g. STK_OPEN_CHANNEL_FLAG_IMMEDIATE,
STK_OEPN_CHANNEL_FLAG_BACKGROUND, etc.

Regards,
-Denis

      reply	other threads:[~2011-03-31 15:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-30 21:41 [PATCH v2 1/2] stkutil: Complete the TLV parsing/builder to support BIP commands Philippe Nunes
2011-03-31  1:26 ` Denis Kenzior
2011-03-31 10:37   ` Philippe Nunes
2011-03-31 15:37     ` Denis Kenzior [this message]

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=4D949FCB.9080908@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