Ionut Nicu wrote, on 11/07/2010 06:11 AM:

Just out of curiosity, in what cases is it acceptable to use
BUG_ON/WARN_ON?
here is my rule for BUG_ON Vs WARN_ON:

imagine this code to be running on your Phone while you are doing sometime important, and this case gets hit - choose:
a) you stop the entire phone - BUG_ON
b) provide a cryptic info - WARN_ON - just the func name with not much additional data
c) provide detailed info : in the order of my personal preference:
dev_dbg/dev_info/dev_err/... -> if there is anychange of getting to the struct device * representing the device
        pr_err/pr_info/pr_warning -> if there is no other alternative

keep in mind - few months from now, code would change, function line numbers change etc.. - I'd usually NOT TOUCH BUG_ON, NOT use WARN_ON unless I am threatened by maintainer, and choose one of (c) based on the location in the code I am at..

I know that some folks think that when a case is reached, they'd like to do a BUG_ON so that the issue is caught and fixed immediately - SORRY, I disagree as I see the code running in a endproduct - and BUG_ONs cause system hang and reboots in an end product - which as a personal user of a great Linux phone like N900 is definitely not my personal preference.

--
Regards,
Nishanth Menon
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to