[hipl-dev] Re: [Merge] lp:~hipl-core/hipl/hipv2-modularization into lp:hipl

  • From: Christof Mroz <christof.mroz@xxxxxxxxxxxxxx>
  • To: hipl-dev@xxxxxxxxxxxxx
  • Date: Thu, 12 Jul 2012 14:34:54 +0200

On 12.07.2012 14:01, Xin wrote:
> I follow your advice to update the code. You can check it in this commit:
> http://bazaar.launchpad.net/~hipl-core/hipl/hipv2-modularization/revision/6257

One more thing, see below :(

> === modified file 'libcore/builder.c'
> --- libcore/builder.c 2012-07-07 13:42:21 +0000
> +++ libcore/builder.c 2012-07-12 11:50:33 +0000
> @@ -109,6 +109,11 @@
>  
>  static enum select_dh_key_t select_dh_key = STRONGER_KEY;
>  
> +enum cbo_flags {
> +    CBO_HTON = true,
> +    CBO_NTOH = false
> +};
> +
>  /**
>   * Convert the byte order of a list of items in one buffer.
>   *
> @@ -118,6 +123,7 @@
>   *                  items in 2 bytes or 4 bytes.
>   * @param hton      if true, perform host-to-network byte order transform,
>   *                  other wise perform network-to-host transform.
> + *                  @see @c cbo_flags.
>   */
>  static void convert_byte_order(void *content, unsigned count,
>                                 unsigned item_size, bool hton)

If you use the enum type rather than bool here, you don't need to
document the "@see ..." part explicitly.
Note that IIRC writing ::identifier creates a hyperlink to `identifier'
in doxygen (and should issue a warning if `identifier' gets deleted),
unlike @c.

Now that I think of it, using true and false for anything but bool is
probably unnecessarily confusing, sorry about that.
I'd rather use opaque numeric values for enums (and avoid to cast them
to bool implicitly), just like everywhere else in HIPL, even if C is
very relaxed about enum and bool.

Other related posts: