While we’re on this topic I would also like to encourage authors to put only one condition in their asserts instead of multiple. So, DEBUGASSERT(cond1) ; DEBUGASSERT (cond2); (…)
Instead of DEBUGASSERT(cond1 && cond2 &&..). When an assertion happens and there’s multiple conditions then I don’t know which one triggered it. Best, Daniel *Daniel Appiagyei | Embedded Software Engineer *Email: daniel.appiag...@braincorp.com <bog...@braincorporation.com>*Brain* * Corp™ *10182 Telesis Ct, Suite 100 San Diego, CA 92121 (858)-689-7600 www.braincorp.com On Fri, Dec 15, 2023 at 3:40 AM Alan C. Assis <acas...@gmail.com> wrote: > I think debugassert() is for finding BUGs during the development/testing > phase. > > In the other hand assert() should be put in case where something really > catastrofic is going to happen and cannot be avoid anyway. > > My personal opinion is that release code shouldn't have (or should have the > minimum as possible) assert() and PANIC(). You don't wasn't want your code > to fail in a critical moment, do you? > > So assert() code could be used during an inicial validation phase in the > field. But of course, if it is a HW issue, there is nothing your code can > do except showing a BSOD. > > BR, > > Alan > > On Thu, Dec 14, 2023 at 11:50 AM Tim Hardisty <timhardist...@gmail.com> > wrote: > > > Hi, > > > > I'm wondering if there is an "approved" usage of assert vs debugassert > > for files/apps in the nuttx-apps repo? > > > > My thinking is: > > > > * use debugassert if a function in apps would only fail if the calling > > code, probably (or possibly only) if other functions within apps, > > rather than an unknown higher level app, have done something dumb > > that should be picked up during nuttx-apps development and so should > > not make it through to final code; but if they do, that's the fault > > of the developer for not turning on debug asserts!! > > * use assert if the error would cause the obviously unknown > > higher-level calling app someone's writing to fail if the error was > > allowed to pass unchecked, so the developer of that higher level app > > can deal with it programmatically. > > > > That might almost suggest that debugassert() is for private functions > > and assert() is for public ones? > > > > Probably over-thinking it as usual, but I'm never afraid to ask :) > > > > Thanks! > > > > TimJTi. > > >