Closed Bug 1359841 Opened 4 years ago Closed 4 years ago

xpcom/base/nsStatusReporterManager.cpp should cast getpid() return value to int

Categories

(Core :: XPCOM, defect)

45 Branch
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla55
Tracking Status
firefox55 --- fixed

People

(Reporter: petr.sumbera, Assigned: petr.sumbera)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (X11; SunOS i86pc; rv:45.0) Gecko/20100101 Firefox/45.0
Build ID: 20170407182535

Steps to reproduce:

/builds/psumbera/userland-ff-52-jinji/components/desktop/firefox/firefox-52.1.0esr/xpcom/base/nsStatusReporterManager.cpp:149:30: error: call of overloaded 'AppendInt(pid_t ' is ambiguous
   filename.AppendInt(getpid());
                              ^
In file included from /builds/psumbera/userland-ff-52-jinji/components/desktop/firefox/build/i86/dist/include/nsAString.h:26:0,
                 from /builds/psumbera/userland-ff-52-jinji/components/desktop/firefox/build/i86/dist/include/nsSubstring.h:10,
                 from /builds/psumbera/userland-ff-52-jinji/components/desktop/firefox/build/i86/dist/include/nsString.h:12,
                 from /builds/psumbera/userland-ff-52-jinji/components/desktop/firefox/build/i86/dist/include/nsStringGlue.h:18,
                 from /builds/psumbera/userland-ff-52-jinji/components/desktop/firefox/build/i86/dist/include/nsThreadUtils.h:19,
                 from /builds/psumbera/userland-ff-52-jinji/components/desktop/firefox/firefox-52.1.0esr/ipc/chromium/src/base/message_loop.h:29,
                 from /builds/psumbera/userland-ff-52-jinji/components/desktop/firefox/firefox-52.1.0esr/xpcom/base/nsDumpUtils.h:11,
                 from /builds/psumbera/userland-ff-52-jinji/components/desktop/firefox/firefox-52.1.0esr/xpcom/base/nsDumpUtils.cpp:7,
                 from /builds/psumbera/userland-ff-52-jinji/components/desktop/firefox/build/i86/xpcom/base/Unified_cpp_xpcom_base1.cpp:2:
/builds/psumbera/userland-ff-52-jinji/components/desktop/firefox/build/i86/dist/include/nsTSubstring.h:579:8: note: candidate: void nsACString_internal::AppendInt(int32_t)
   void AppendInt(int32_t aInteger)
        ^
/builds/psumbera/userland-ff-52-jinji/components/desktop/firefox/build/i86/dist/include/nsTSubstring.h:588:8: note: candidate: void nsACString_internal::AppendInt(uint32_t)
   void AppendInt(uint32_t aInteger)
        ^
/builds/psumbera/userland-ff-52-jinji/components/desktop/firefox/build/i86/dist/include/nsTSubstring.h:597:8: note: candidate: void nsACString_internal::AppendInt(int64_t)
   void AppendInt(int64_t aInteger)
        ^
/builds/psumbera/userland-ff-52-jinji/components/desktop/firefox/build/i86/dist/include/nsTSubstring.h:606:8: note: candidate: void nsACString_internal::AppendInt(uint64_t)
   void AppendInt(uint64_t aInteger)
        ^


This is happening on Solaris when building 32bit binary. The reason is because pid_t is in this case defined as long. Linux and Solaris in 64bit mode defines pid_t as int.

There seems to be similar case handled in xpcom/base/nsTraceRefcnt.cpp where is:

name.AppendInt((uint32_t)getpid());

So I think we should follow this example.
Attached patch Bug1359841.patchSplinter Review
Attachment #8861994 - Flags: review?(alchen)
Component: Untriaged → XPCOM
Product: Firefox → Core
Comment on attachment 8861994 [details] [diff] [review]
Bug1359841.patch

Review of attachment 8861994 [details] [diff] [review]:
-----------------------------------------------------------------

LGTM
Attachment #8861994 - Flags: review?(alchen) → review+
Keywords: checkin-needed
Assignee: nobody → petr.sumbera
Pushed by ryanvm@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/eeac6d080b44
xpcom/base/nsStatusReporterManager.cpp should cast getpid() return value to int. r=alchen
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/eeac6d080b44
Status: UNCONFIRMED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla55
You need to log in before you can comment on or make changes to this bug.