svn commit: r332072 - head/sys/sys

Bruce Evans brde at optusnet.com.au
Thu Apr 5 15:23:10 UTC 2018


On Thu, 5 Apr 2018, [UTF-8] Roger Pau Monné wrote:

> Log:
>  introduce GiB and MiB macros
>
>  This macros convert from GiB or MiB into bytes.

This is undocumented namspace pollution with bad names and worse types.

The better names GB and MB would be more likely to conflicted with
code not written by disk marketers.

> Modified: head/sys/sys/param.h
> ==============================================================================
> --- head/sys/sys/param.h	Thu Apr  5 14:25:39 2018	(r332071)
> +++ head/sys/sys/param.h	Thu Apr  5 14:31:54 2018	(r332072)
> @@ -362,4 +362,8 @@ __END_DECLS
>  */
> #define __PAST_END(array, offset) (((__typeof__(*(array)) *)(array))[offset])

Old style bug: space instead of tab after #define.

>
> +/* Unit conversion macros. */
> +#define GiB(v) (v ## ULL << 30)
> +#define MiB(v) (v ## ULL << 20)
> +

New style bugs:
- space instead of tab after #define
- use of the long long abomination

Type error:
- the abomination doesn't have the same type of carefully typedefed types
   like vm_size_t on any supported arch.

> #endif	/* _SYS_PARAM_H_ */

Old style bugs:
- tab instead of space before comment on #endif.
- backwards comment on #endif.

Bruce


More information about the svn-src-head mailing list