From: Marc Schink Date: Fri, 2 Apr 2021 09:17:00 +0000 (+0200) Subject: doc/manual/style: Do not use 'Yoda conditions' X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=134d7d5a5876a53a10ecb2eeac8d193bdddcea81;p=fw%2Fopenocd doc/manual/style: Do not use 'Yoda conditions' For more details, see: https://en.wikipedia.org/wiki/Yoda_conditions https://sektorvanskijlen.wordpress.com/2019/05/16/conditional-inversion-very-harmful-myth/ Change-Id: If1a8a5f1d0fd345b7cc0c7b5dee6d0d47f9d7fc2 Signed-off-by: Marc Schink Reviewed-on: http://openocd.zylin.com/6132 Reviewed-by: Tarek BOCHKATI Tested-by: jenkins Reviewed-by: Oleksij Rempel Reviewed-by: Antonio Borneo Reviewed-by: Tomas Vanek --- diff --git a/doc/manual/style.txt b/doc/manual/style.txt index dad3bb440..c3fcfd782 100644 --- a/doc/manual/style.txt +++ b/doc/manual/style.txt @@ -135,13 +135,13 @@ should write statements like the following: @code // separate statements should be preferred result = foo(); -if (ERROR_OK != result) +if (result != ERROR_OK) ... @endcode More directly, do @b not combine these kinds of statements: @code // Combined statements should be avoided -if (ERROR_OK != (result = foo())) +if ((result = foo()) != ERROR_OK) return result; @endcode