From 3cf4717a2aacfc197e1b6e84cf5a3391ba5585fb Mon Sep 17 00:00:00 2001 From: zwelch Date: Wed, 8 Jul 2009 22:26:42 +0000 Subject: [PATCH] Add style rule to avoid combining assignment and logical tests. git-svn-id: svn://svn.berlios.de/openocd/trunk@2503 b42882b7-edfa-0310-969c-e2dbd0fdcd60 --- doc/manual/style.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/doc/manual/style.txt b/doc/manual/style.txt index b9a7612f..0fe33876 100644 --- a/doc/manual/style.txt +++ b/doc/manual/style.txt @@ -106,6 +106,20 @@ int f(int x1, int x2) int y = f(x1, x2 - x1); ... } +@endcode +- Separate assignment and logical test statements. In other words, you +should write statements like the following: +@code +// separate statements should be preferred +result = foo(); +if (ERROR_OK != result) + ... +@endcode +More directly, do @b not combine these kinds of statements: +@code +// Combined statements should be avoided +if (ERROR_OK != (result = foo())) + return result; @endcode */ -- 2.39.5