All,

I am a little concerned the coding conventions getting too pedantic lately.

While I agree magic numbers should be avoided, I disagree to introduce #defines for every single one of them as I do with introducing a static check for it. (Using a #define for a number only used once in HW initialization for example
seems too much to me.)

I agree however with putting a comment with an explanation or data sheet reference
to each occurrence.
(Register initializations should use or'ed bit defines from vendor headers anyways.) To me it is the duty of the maintainer reviewing the code to decide if it makes sense to use a #define or a comment is enough. Thus I'd prefer a best practice
instead of a rule.

Best, Thomas

On 4 Jul 2016, at 9:20 CEST(+0200), Ludwig Knüpfer wrote:

On Mon, Jul 04, 2016 at 07:44:21AM +0200, Ludwig Knüpfer wrote:
Am 2. Juli 2016 13:21:19 MESZ, schrieb Kees Bakker <k...@sodaq.com>:
While going through the code I notice that there are too many "magic"
constants. Hard coded numbers that are obvious for some, but not
obvious
for others. My advise: always try to use defines and add a comment
about
what constants mean. Or point to datasheet sections explaining the
constants.

Thank you for bringing this up.

I am uncertain if there is something that can be done about it in the existing code base, but at least we should find a way to prevent such issues in the future:

There is an "immediately" missing in the sentence above... I guess
there's quite a few of these ;)

Cheers,
Ludwig
_______________________________________________
devel mailing list
devel@riot-os.org
https://lists.riot-os.org/mailman/listinfo/devel
_______________________________________________
devel mailing list
devel@riot-os.org
https://lists.riot-os.org/mailman/listinfo/devel

Reply via email to