@code{error} case or the significantly simpler continuation. For example:
@example
-if (0 != stat ("filename," &sbuf)) @{
+if (0 != stat ("filename,"
+ &sbuf))
+@{
error();
- @}
- else @{
- /* handle normal case here */
- @}
+@}
+else
+@{
+ /* handle normal case here */
+@}
@end example
@noindent
should be omitted:
@example
-if (0 != stat ("filename," &sbuf)) @{
+if (0 != stat ("filename",
+ &sbuf))
+@{
error();
return;
- @}
+@}
/* handle normal case here */
@end example
code clarity. For example, one can write:
@example
-if (NULL == (value = lookup_function())) @{
+if (NULL == (value = lookup_function()))
+@{
error();
return;
- @}
+@}
@end example
@item Use @code{break} and @code{continue} wherever possible to avoid
@example
next = head;
-while (NULL != (pos = next)) @{
+while (NULL != (pos = next))
+@{
next = pos->next;
if (! should_free (pos))
continue;
- GNUNET_CONTAINER_DLL_remove (head, tail, pos);
+ GNUNET_CONTAINER_DLL_remove (head,
+ tail,
+ pos);
GNUNET_free (pos);
- @}
+@}
@end example
instead of
next = pos->next;
if (! should_free (pos))
continue;
- GNUNET_CONTAINER_DLL_remove (head, tail, pos);
+ GNUNET_CONTAINER_DLL_remove (head,
+ tail,
+ pos);
GNUNET_free (pos);
@}
@end example
@code{cls} argument to the precise expected type. For example:
@example
-int callback (void *cls, char *args) @{
+int
+callback (void *cls,
+ char *args)
+@{
struct Foo *foo = cls;
int other_variables;
@}
@end example
+@item As shown in the example above, after the return type of a
+function there should be a break. Each parameter should
+be on a new line.
@item It is good practice to write complex @code{if} expressions instead
of using deeply nested @code{if} statements. However, except for addition
and multiplication, all operators should use parens. This is fine:
@example
-if ( (1 == foo) || ((0 == bar) && (x != y)) )
+if ( (1 == foo) ||
+ ( (0 == bar) &&
+ (x != y) ) )
return x;
@end example
This is WIP. Endpoints should be documented appropriately.
Preferably using annotations.
-