Closed Bug 243130 Opened 20 years ago Closed 20 years ago

nsLocalMailFolder.cpp: Cannot assign const char* to char*

Categories

(MailNews Core :: Backend, defect)

Sun
Solaris
defect
Not set
major

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: mozbugs, Assigned: Bienvenu)

Details

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7) Gecko/20040507 Firefox/0.8.0+
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7) Gecko/20040507 Firefox/0.8.0+


Can't build mozilla or tunderbird from the trunk on Solaris with Sun Studio
compiler:

"nsLocalMailFolder.cpp", line 3032: Error: Cannot assign const char* to char*.
"nsLocalMailFolder.cpp", line 3055: Error: Cannot assign const char* to char*.
2 Error(s) detected.
gmake[5]: *** [nsLocalMailFolder.o] Error 2
gmake[5]: Leaving directory
`/export/stuff/mozilla/mozilla-20040508/mozilla/mailnews/local/src'


Reproducible: Always
Steps to Reproduce:
1.
2.
3.





Couldn't see an applicable component under mailnews for this ???
OS: other → Solaris
Hardware: Other → Sun
This is fallout from bienvenu's changes for bug 30057.
so, this got added as part of:
1.456 <bienvenu@nventure.com> 2004-05-08 08:35

But _why_ does strstr return a constant string??
Assignee: general → sspitzer
Component: Browser-General → Mail Back End
Product: Browser → MailNews
QA Contact: general
Attached patch proposed fixSplinter Review
this should fix it...
Assignee: sspitzer → bienvenu
Status: UNCONFIRMED → ASSIGNED
Attachment #148070 - Flags: superreview?(sspitzer)
Comment on attachment 148070 [details] [diff] [review]
proposed fix

the reason it returns a constant string is that strstr can take a constant
string as input :).

#define STRSTR(haystack, needle) (haystack+(strstr(haystack,
needle)-haystack)).

The better question is why do some clibraries return a non const string?
the result is this compiling code:

#include <string.h>
#include <stdio.h>
const char readonly[]="read only\n"; const char crash[]="crash";
int main(void){
 char *crashonly; const char *crasher;
 crashonly=strstr(readonly,"r"); crasher=crash;
 do { *crashonly++=*crasher++; } while(*crasher);
 puts(readonly); return 0;
}
Attachment #148070 - Flags: review+
(In reply to comment #3)
> Created an attachment (id=148070)
> proposed fix
> 
> this should fix it...

Confirmed with mozilla trunk and thunderbird trunk builds.
Status: ASSIGNED → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Attachment #148070 - Flags: superreview?(sspitzer)
Product: MailNews → Core
Product: Core → MailNews Core
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: