Last Comment Bug 455424 - nssilckt.h defines the enumeration constant 'Lock', which conflicts with C++ code defining a 'Lock' class.
: nssilckt.h defines the enumeration constant 'Lock', which conflicts with C++ ...
Status: RESOLVED FIXED
:
Product: NSS
Classification: Components
Component: Libraries (show other bugs)
: unspecified
: All All
: -- normal (vote)
: 3.12.2
Assigned To: Wan-Teh Chang
:
:
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-09-15 17:05 PDT by Wan-Teh Chang
Modified: 2008-10-17 20:22 PDT (History)
2 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---


Attachments
Proposed patch (1.71 KB, patch)
2008-09-15 17:05 PDT, Wan-Teh Chang
no flags Details | Diff | Splinter Review
Proposed patch v2 (4.95 KB, patch)
2008-09-16 10:25 PDT, Wan-Teh Chang
alvolkov.bgs: review+
Details | Diff | Splinter Review
Proposed patch v3 (as checked in) (4.94 KB, patch)
2008-10-17 20:22 PDT, Wan-Teh Chang
no flags Details | Diff | Splinter Review

Description Wan-Teh Chang 2008-09-15 17:05:32 PDT
Created attachment 338767 [details] [diff] [review]
Proposed patch

nssilckt.h defines the enumeration constant 'Lock' unconditionally:

typedef enum  {
    FlushTT = 0,
    NewLock = 1,
    Lock = 2,  <=== PROBLEM!
    Unlock = 3,
    DestroyLock = 4,
    NewCondVar = 5,
    WaitCondVar = 6,
    NotifyCondVar = 7,
    NotifyAllCondVar = 8,
    DestroyCondVar = 9,
    NewMonitor = 10,
    EnterMonitor = 11,
    ExitMonitor = 12,
    Notify = 13,
    NotifyAll = 14,
    Wait = 15,
    DestroyMonitor = 16
} nssILockOp;

This conflicts with C++ code that defines a 'Lock' class.

The fix is to move the definition of this enumeration type
into conditionally compiled code.  My proposed patch also
removes PR_BEGIN_EXTERN_C and PR_END_EXTERN_C, which are
not used in our xxxt.h headers by convention.
Comment 1 Nelson Bolyard (seldom reads bugmail) 2008-09-15 19:55:33 PDT
Is this a public header file?
Comment 3 Wan-Teh Chang 2008-09-16 10:25:46 PDT
Created attachment 338889 [details] [diff] [review]
Proposed patch v2

I added a test case.  Since the C++ rules in coreconf have rotted,
I created the test case in C even though the originally reported problem
is in C++.
Comment 4 Alexei Volkov 2008-10-15 12:27:49 PDT
Comment on attachment 338889 [details] [diff] [review]
Proposed patch v2

r=alexei
Comment 5 Wan-Teh Chang 2008-10-17 20:22:19 PDT
Created attachment 343678 [details] [diff] [review]
Proposed patch v3 (as checked in)

I changed the test program conflict.c to include "nssilckt.h" directly.
I checked in this patch on the NSS trunk (NSS 3.12.2).

RCS file: /cvsroot/mozilla/security/nss/cmd/tests/conflict.c,v
done
Checking in cmd/tests/conflict.c;
/cvsroot/mozilla/security/nss/cmd/tests/conflict.c,v  <--  conflict.c
initial revision: 1.1
done
Checking in cmd/tests/manifest.mn;
/cvsroot/mozilla/security/nss/cmd/tests/manifest.mn,v  <--  manifest.mn
new revision: 1.7; previous revision: 1.6
done
Checking in lib/util/nssilckt.h;
/cvsroot/mozilla/security/nss/lib/util/nssilckt.h,v  <--  nssilckt.h
new revision: 1.7; previous revision: 1.6
done

Note You need to log in before you can comment on or make changes to this bug.