Skip to contentSkip to conversation

irq-gic: use BUG_ON instead of if()/BUG

PATCH Maninder Singh 2 participants 2 messages Jun 19, 2015

lore
Share & tools
lore
#0 lore raw

Hi Thomas,

Quoted 10 lines

Review

Quoted 6 lines

{

(quoted diff) +1 -2
-	if (gic_nr >= MAX_GIC_NR)
-		BUG();
+	BUG_ON(gic_nr >= MAX_GIC_NR);
 	if (irq_set_handler_data(irq, &gic_data[gic_nr]) != 0)
 		BUG();

So this patch was clearly done just by running a script and not sanity checked afterwards. Otherwise the next if() BUG(); construct would have been fixed as well.

Yes semantic patch did the changes to use preferred APIs,
And it also changed this BUG_ON(irq_set_handler_data(irq, &gic_data[gic_nr]) != 0) But we have to take care that condition has no side effects i.e.

if()/BUG conversion to BUG_ON must be avoided when there's side effect in condition. The reason being BUG_ON won't execute the condition when CONFIG_BUG is not defined As suggested by Julia Lawall

Thats why did not take that change --> (BUG_ON(irq_set_handler_data(irq, &gic_data[gic_nr]) != 0))

Quoted 5 lines

Further, while we are at that. It would be even more useful to analyze whether the BUG_ON() is needed in the first place or at least could be made conditional on some debug option.

But that's not done by the script either, right?

Yes coccinelle semantic patches did not do that changes.
we have to choose whether to make BUG_ON conditional on some debug options.

Thanks,
Maninder

ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ¥Šwÿº{.nÇ+‰·¥Š{±þG«�éÿŠ{ayºʇڙë,j­¢f£¢·hš�ï�êÿ‘êçz_è®(­éšŽŠÝ¢j"�ú¶m§ÿÿ¾«þG«�éÿ¢¸?™¨è­Ú&£ø§~�á¶iO•æ¬z·švØ^¶m§ÿÿà ÿ¶ìÿ¢¸?–I¥

#1 lore raw
Quoted 17 lines · Maninder Singh

Hi Thomas,

Quoted 10 lines

Review

Quoted 6 lines

{

(quoted diff) +1 -2
-	if (gic_nr >= MAX_GIC_NR)
-		BUG();
+	BUG_ON(gic_nr >= MAX_GIC_NR);
 	if (irq_set_handler_data(irq, &gic_data[gic_nr]) != 0)
 		BUG();

So this patch was clearly done just by running a script and not sanity checked afterwards. Otherwise the next if() BUG(); construct would have been fixed as well.

Yes semantic patch did the changes to use preferred APIs,
And it also changed this BUG_ON(irq_set_handler_data(irq, &gic_data[gic_nr]) != 0) But we have to take care that condition has no side effects i.e.

Quoted 5 lines

if()/BUG conversion to BUG_ON must be avoided when there's side effect in condition. The reason being BUG_ON won't execute the condition when CONFIG_BUG is not defined As suggested by Julia Lawall

Thats why did not take that change --> (BUG_ON(irq_set_handler_data(irq, &gic_data[gic_nr]) != 0))

Fair enough. But you should mention that in the changelog.

Quoted 8 lines
Quoted 5 lines

Further, while we are at that. It would be even more useful to analyze whether the BUG_ON() is needed in the first place or at least could be made conditional on some debug option.

But that's not done by the script either, right?

Yes coccinelle semantic patches did not do that changes.
we have to choose whether to make BUG_ON conditional on some debug options.

Right, and that's what I'm asking for. IOW, instead of blindly running scripts at least ask the question whether this stuff needs to be there unconditionally....

Such information can be put into the changelog and helps the reviewers to distinguish thoughtful people from script bots.

Thanks,

tglx