aboutsummaryrefslogtreecommitdiff
path: root/doc/handbook/chapters
diff options
context:
space:
mode:
Diffstat (limited to 'doc/handbook/chapters')
-rw-r--r--doc/handbook/chapters/developer.texi50
1 files changed, 34 insertions, 16 deletions
diff --git a/doc/handbook/chapters/developer.texi b/doc/handbook/chapters/developer.texi
index 6c426ebad..c18614549 100644
--- a/doc/handbook/chapters/developer.texi
+++ b/doc/handbook/chapters/developer.texi
@@ -902,12 +902,15 @@ accidental assignment) and with the @code{true} target being either the
902@code{error} case or the significantly simpler continuation. For example: 902@code{error} case or the significantly simpler continuation. For example:
903 903
904@example 904@example
905if (0 != stat ("filename," &sbuf)) @{ 905if (0 != stat ("filename,"
906 &sbuf))
907@{
906 error(); 908 error();
907 @} 909@}
908 else @{ 910else
909 /* handle normal case here */ 911@{
910 @} 912 /* handle normal case here */
913@}
911@end example 914@end example
912 915
913@noindent 916@noindent
@@ -927,10 +930,12 @@ If possible, the error clause should be terminated with a @code{return} (or
927should be omitted: 930should be omitted:
928 931
929@example 932@example
930if (0 != stat ("filename," &sbuf)) @{ 933if (0 != stat ("filename",
934 &sbuf))
935@{
931 error(); 936 error();
932 return; 937 return;
933 @} 938@}
934/* handle normal case here */ 939/* handle normal case here */
935@end example 940@end example
936 941
@@ -943,10 +948,11 @@ NULL, and enums). With the two above rules (constants on left, errors in
943code clarity. For example, one can write: 948code clarity. For example, one can write:
944 949
945@example 950@example
946if (NULL == (value = lookup_function())) @{ 951if (NULL == (value = lookup_function()))
952@{
947 error(); 953 error();
948 return; 954 return;
949 @} 955@}
950@end example 956@end example
951 957
952@item Use @code{break} and @code{continue} wherever possible to avoid 958@item Use @code{break} and @code{continue} wherever possible to avoid
@@ -954,13 +960,16 @@ deep(er) nesting. Thus, we would write:
954 960
955@example 961@example
956next = head; 962next = head;
957while (NULL != (pos = next)) @{ 963while (NULL != (pos = next))
964@{
958 next = pos->next; 965 next = pos->next;
959 if (! should_free (pos)) 966 if (! should_free (pos))
960 continue; 967 continue;
961 GNUNET_CONTAINER_DLL_remove (head, tail, pos); 968 GNUNET_CONTAINER_DLL_remove (head,
969 tail,
970 pos);
962 GNUNET_free (pos); 971 GNUNET_free (pos);
963 @} 972@}
964@end example 973@end example
965 974
966instead of 975instead of
@@ -987,7 +996,9 @@ while (NULL != (pos = next))
987 next = pos->next; 996 next = pos->next;
988 if (! should_free (pos)) 997 if (! should_free (pos))
989 continue; 998 continue;
990 GNUNET_CONTAINER_DLL_remove (head, tail, pos); 999 GNUNET_CONTAINER_DLL_remove (head,
1000 tail,
1001 pos);
991 GNUNET_free (pos); 1002 GNUNET_free (pos);
992@} 1003@}
993@end example 1004@end example
@@ -1018,7 +1029,10 @@ be part of the variable declarations, should assign the
1018@code{cls} argument to the precise expected type. For example: 1029@code{cls} argument to the precise expected type. For example:
1019 1030
1020@example 1031@example
1021int callback (void *cls, char *args) @{ 1032int
1033callback (void *cls,
1034 char *args)
1035@{
1022 struct Foo *foo = cls; 1036 struct Foo *foo = cls;
1023 int other_variables; 1037 int other_variables;
1024 1038
@@ -1026,13 +1040,18 @@ int callback (void *cls, char *args) @{
1026@} 1040@}
1027@end example 1041@end example
1028 1042
1043@item As shown in the example above, after the return type of a
1044function there should be a break. Each parameter should
1045be on a new line.
1029 1046
1030@item It is good practice to write complex @code{if} expressions instead 1047@item It is good practice to write complex @code{if} expressions instead
1031of using deeply nested @code{if} statements. However, except for addition 1048of using deeply nested @code{if} statements. However, except for addition
1032and multiplication, all operators should use parens. This is fine: 1049and multiplication, all operators should use parens. This is fine:
1033 1050
1034@example 1051@example
1035if ( (1 == foo) || ((0 == bar) && (x != y)) ) 1052if ( (1 == foo) ||
1053 ( (0 == bar) &&
1054 (x != y) ) )
1036 return x; 1055 return x;
1037@end example 1056@end example
1038 1057
@@ -8989,4 +9008,3 @@ so please make sure that endpoints are unambiguous.
8989 9008
8990This is WIP. Endpoints should be documented appropriately. 9009This is WIP. Endpoints should be documented appropriately.
8991Preferably using annotations. 9010Preferably using annotations.
8992