Closed Bug 606270 Opened 15 years ago Closed 15 years ago

xpcjsruntime.cpp:1072: warning: ignoring return value of 'int moz_posix_memalign(void**, size_t, size_t)', declared with attribute warn_unused_result

Categories

(Core :: XPConnect, defect)

All
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla2.0b8

People

(Reporter: dholbert, Assigned: dholbert)

References

Details

(Whiteboard: [build_warning])

Attachments

(1 file)

js/src/xpconnect/src/xpcjsruntime.cpp: In member function 'virtual void* XPConnectGCChunkAllocator::doAlloc()': js/src/xpconnect/src/xpcjsruntime.cpp:1072: warning: ignoring return value of 'int moz_posix_memalign(void**, size_t, size_t)', declared with attribute warn_unused_result References: http://mxr.mozilla.org/mozilla-central/source/js/src/xpconnect/src/xpcjsruntime.cpp#1072 http://mxr.mozilla.org/mozilla-central/source/memory/mozalloc/mozalloc.h#149 The code in question is: 1069 virtual void *doAlloc() { 1070 void *chunk = 0; 1071 #ifdef MOZ_MEMORY 1072 posix_memalign(&chunk, js::GC_CHUNK_SIZE, js::GC_CHUNK_SIZE); 1073 #else 1074 chunk = js::AllocGCChunk(); 1075 #endif 1076 if (chunk) 1077 mNumGCChunksInUse++; 1078 return chunk; 1079 } (note that posix_memalign is #defined to moz_posix_memalign in my configuration) So posix_memalign returns an error code on failure. The flagged code assumes that it'll *also* leave |chunk| unmodified (or null it out) on failure. However, the man page for posix_memalign doesn't make that guarantee: http://www.opengroup.org/onlinepubs/000095399/functions/posix_memalign.html So, I think we should be checking the return value here. (particularly since the function's declaration asks us to)
Attached patch fixSplinter Review
Assignee: nobody → dholbert
Status: NEW → ASSIGNED
Attachment #485086 - Flags: review?(vladimir)
Comment on attachment 485086 [details] [diff] [review] fix Requesting approval to land on mozilla-central. This is a correctness fix to fix a build warning; no anticipated functional change.
Attachment #485086 - Flags: approval2.0?
Whiteboard: [build_warning] → [build_warning][needs landing]
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Whiteboard: [build_warning][needs landing] → [build_warning]
Target Milestone: --- → mozilla2.0b8
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: