Closed Bug 129533 Opened 23 years ago Closed 23 years ago

|Cannot use const char* to initialize char*| bustage

Categories

(SeaMonkey :: Build Config, defect)

Sun
Solaris
defect
Not set
blocker

Tracking

(Not tracked)

VERIFIED FIXED

People

(Reporter: roland.mainz, Assigned: netscape)

References

Details

Attachments

(2 files, 1 obsolete file)

2002-03-06-08-trunk build with Sun Workshop 7EA2. The build breaks due some
|Cannot use const char* to initialize char*| errors in the code ("nebiros" is
gone from the Seamonkey-Ports page, there is no RED tinderbox but it will be RED
once it's "up" again...) ...
Looks fine, r=/sr=jag.

Darin, what do you think?
Comment on attachment 73017 [details] [diff] [review]
Patch for 2002-03-06-08-trunk

sr=darin
Attachment #73017 - Flags: superreview+
Attachment #73017 - Flags: review+
*** Bug 129619 has been marked as a duplicate of this bug. ***
Comment on attachment 73017 [details] [diff] [review]
Patch for 2002-03-06-08-trunk

a=asa (on behalf of drivers) for checkin to the 1.0 trunk
Attachment #73017 - Flags: approval+
Patch has been checked in
Status: NEW → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
nsMsgUtils.cpp also has the same problem.
"nsMsgUtils.cpp", line 416: Error: Cannot use const char* to initialize 
416 and 410 line:
-------------------------
char*.    if (s != decodedString.get())
    {
      // extract between "=?" and "?"
      // e.g. =?ISO-2022-JP?
->416 char *p1 = strstr(*stringP, "=?");
      if (p1)
      {
        p1 += sizeof("=?")-1;         // skip "=?"
->420   char *p2 = strchr(p1, '?');   // then search for '?'
        if (p2)
        {
          char charset[kMAX_CSNAME] = "";
----------------------------
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Attached patch nsMsgUtils.cppSplinter Review
Patch to fix nsMsgUtils.cpp
taking a guess that this is related to the problem I filed about it: bug 129994.
shouldn't use strstr function,we should usr PL_strstr,it will let mozilla build 
ok on sun Platform.
Antonio.Xu wrote:
> shouldn't use strstr function, we should usr PL_strstr, it will let mozilla 
> build ok on sun Platform.

Well, then the prototype for PL_strstr() is wrong and should be fixed. And then
we have the same problem...

BTW: We should always use the OS native functions if possible and available,
they are usually better optimised and/or |inline| or compiler buildins
(currently we are slaughtering most stuff in nsCRT::* for that reason...) ...
i'm 80% certain strstr isn't available from all c libraries, so for now, please 
use the PL_ version and contact nspr about any prototype issues.
timeless, see:

netwerk/protocol/data/src/nsDataChannel.cpp:
    char *buffer = strstr(spec.get(), "data:");

netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp:
        char* eol = strstr(currLine, CRLF);

so, i think strstr should be ok to use.
See Kernighan and Ritchie, The C Programming Language, 2nd. Ed.,
page 250.  The function strstr() is documented.
Comment on attachment 73452 [details] [diff] [review]
nsMsgUtils.cpp

a=asa (on behalf of drivers) for checkin to the 1.0 trunk
Attachment #73452 - Flags: approval+
Patch checked in.
Status: REOPENED → RESOLVED
Closed: 23 years ago23 years ago
Resolution: --- → FIXED
This has just (approximately 3/30/02) shown up in a new spot 

 mozilla/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp

suggest the following fix

485c485
<         char* eol = strstr(currLine, CRLF);
---
>         char* eol = (char *) strstr(currLine, CRLF);

no. patch coming up
Attached patch correct fix for bbaetz's (obsolete) — Splinter Review
Comment on attachment 76965 [details] [diff] [review]
correct fix for bbaetz's

r=bryner
Attachment #76965 - Flags: review+
Comment on attachment 76965 [details] [diff] [review]
correct fix for bbaetz's

sr=darin
Attachment #76965 - Flags: superreview+
Seeing this problem on todays Sun Solaris cvs

"nsFtpConnectionThread.cpp" , line 485: Error: Cannot use const char* to
initialize  char*.


Lets get this checked in so I can start getting Solaris dailys built and tested
again.

Thanks

Donnie

-dcran-
Comment on attachment 76965 [details] [diff] [review]
correct fix for bbaetz's

checked in a=asa
Attachment #76965 - Attachment is obsolete: true
Attachment #76965 - Flags: approval+
verfied checked in
Status: RESOLVED → VERIFIED
Product: Browser → Seamonkey
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: