[systemd-devel] [PATCH] use static_assert instead of assert_cc

Thomas H.P. Andersen phomes at gmail.com
Thu Jan 3 13:47:47 PST 2013


On Thu, Jan 3, 2013 at 10:34 PM, Lennart Poettering
<lennart at poettering.net> wrote:
> On Sat, 29.12.12 02:10, Thomas H.P. Andersen (phomes at gmail.com) wrote:
>
>> Another item from the todo
>
> Heya!
>
> Hmm, so I commited a patch for using assert_static() a few days before
> you did your patches but unfortunately never commited it.
>
> It works a bit differently from your patch, i.e. keeps assert_cc() as
> special version of assert_static() around which only takes one rather
> than two parameters and generates the message from the passed
> expression.
>
> I am tempted to just leave this code now as I commited it, since having
> to pass an explicit string to assert_static() is sometimes a bit
> redundant i'd say, and doesn't really make things more readable unless
> the expression that is tested is really complicated.
>
> Hence, I'd say that we should use assert_cc() and assert_static() from
> now on like this:
>
> assert_cc() for simple expressions where the expression is readable
> enough as is.
>
> assert_static() for complex expressions where it is worth specifying a
> human readable string.
>
> I hope this makes sense?

yeah, makes sense. It also does not break the build for older
compilers :) Do you see warnings about mixed declarations and code? I
had to move some of the asserts to avoid that with my patch.


More information about the systemd-devel mailing list