<div dir="ltr"><div><div><div><div>Thank you all for your input.<br></div> I went for option 3 after all the advice.<br></div>Volker can you explain WHY to never return 1 as fail.<br></div>Usually I leave return type as uint8_t reserving 0 for success and any positive number being a failure where the value is specific to the function. So in this case failure is !0 8)<br><br></div>No much refactoring to do next holidays...<br></div><div class="gmail_extra"><br><div class="gmail_quote">On 8 February 2016 at 17:55, Volker Kuhlmann <span dir="ltr"><<a href="mailto:list0570@paradise.net.nz" target="_blank">list0570@paradise.net.nz</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Fri 05 Feb 2016 19:09:06 NZDT +1300, Col wrote:<br>
<br>
> Return TRUE or FALSE to make code more structured and readable<br>
><br>
> eg<br>
><br>
> if( readSomePIN(...) )<br>
>       //process result<br>
> else<br>
>       //deal with error<br>
<br>
</span>1) Do not return TRUE or FALSE, return PASS or FAIL. (And<br>
define one as 0, and the other as !0 - never define as 1.)<br>
<br>
2) If you need more than binary status, return error code enum (note:<br>
OK == 0 in this case) and make your function return type err_t:<br>
<br>
typedef enum {<br>
        E_OK,<br>
        E_WHATEVER<br>
} err_t;<br>
<br>
Volker<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Volker Kuhlmann<br>
<a href="http://volker.top.geek.nz/" rel="noreferrer" target="_blank">http://volker.top.geek.nz/</a>      Please do not CC list postings to me.<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
_______________________________________________<br>
Chchrobotics mailing list <a href="mailto:Chchrobotics@lists.linuxnut.co.nz">Chchrobotics@lists.linuxnut.co.nz</a><br>
<a href="http://lists.ourshack.com/mailman/listinfo/chchrobotics" rel="noreferrer" target="_blank">http://lists.ourshack.com/mailman/listinfo/chchrobotics</a><br>
Mail Archives: <a href="http://lists.ourshack.com/pipermail/chchrobotics/" rel="noreferrer" target="_blank">http://lists.ourshack.com/pipermail/chchrobotics/</a><br>
Meetings usually 3rd Monday each month. See <a href="http://kiwibots.org" rel="noreferrer" target="_blank">http://kiwibots.org</a> for venue, directions and dates.<br>
When replying, please edit your Subject line to reflect new subjects.<br>
</div></div></blockquote></div><br></div>