Closed Bug 517370 Opened 15 years ago Closed 6 years ago

alwayszero function attribute for gcc

Categories

(Developer Infrastructure :: Source Code Analysis, defect)

x86
Linux
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED INACTIVE

People

(Reporter: taras.mozilla, Assigned: ehren.m)

References

Details

(Keywords: student-project)

Attachments

(4 files)

In mozilla we have a lot of functions that always return NS_OK(0). This means that callers of such functions usually have unneeded error checking. nsresult rv = call(); if (NS_FAILED(rv)....) <-- gcc should be able to optimize this away if it knows that value of call() is always zero For reference see gcc function attributes: pure, const. and Gcc variable attribute nonnull(I don't see that one in the docs anymore, is it gone?).
alternatively/additionally we should do static analysis to ensure that always zerofunctions a) only ever return 0 b) never have their return value checked
Assignee: nobody → ehren.m
Status: NEW → ASSIGNED
This has a problem with being able to print off the class location of a method with a misapplied attribute. Being a ripoff of outparams.js, there may still be some unnecessary code as well.
there are some indenting issues here, particularly when a declaration is broken over several lines.
Attached file Makefile for alwayszero_plugin.c (deleted) —
compile with make CC=/path/to/plugin-enabled/gcc (requires plugin framework from GCC 4.5)
Attachment #416042 - Attachment mime type: text/x-csrc → text/plain
Attachment #416043 - Attachment mime type: application/octet-stream → text/plain
Not sure if all of this is ready for review yet. For one thing when FIND_NEW_FUNCTIONS = true, a whole lot of output will be printed during static analysis builds. There's also a lot more patching to be done (likely with Pork).
Product: Core → Firefox Build System
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → INACTIVE
Product: Firefox Build System → Developer Infrastructure
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: