WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
62222
JSStaticFunction and JSStaticValue are overly "const"
https://bugs.webkit.org/show_bug.cgi?id=62222
Summary
JSStaticFunction and JSStaticValue are overly "const"
Juan C. Montemayor
Reported
2011-06-07 11:29:22 PDT
10/3/06 2:30 PM by John Harper: * SUMMARY JSStaticFunction has this definition: typedef struct { const char* const name; // FIXME: convert UTF8 JSObjectCallAsFunctionCallback callAsFunction; JSPropertyAttributes attributes; } JSStaticFunction; which means that it's impossible to initialize the name field dynamically. E.g. this code: JSStaticFunction *fun; fun->name = "something"; fails with a compiler error. There is no reason for the second of those two "const" qualifiers? A cast will be needed to set the structure field.. [...] it definitely gives a warning for me, in test.c: #include <JavaScriptCore/JavaScriptCore.h> static void foo (void) { JSStaticFunction *fun; fun->name = "something"; } then: $ cc -c test.c test.c: In function 'foo': test.c:7: error: assignment of read-only member 'name' in my actual code I did this: *(void **)&funptr->name = (void *) m->desc->jsName;
Attachments
proposed patch
(2.42 KB, patch)
2011-06-07 11:38 PDT
,
Juan C. Montemayor
ggaren
: review-
ggaren
: commit-queue-
Details
Formatted Diff
Diff
proposed patch
(2.42 KB, patch)
2011-06-07 15:20 PDT
,
Juan C. Montemayor
no flags
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Juan C. Montemayor
Comment 1
2011-06-07 11:38:03 PDT
Created
attachment 96270
[details]
proposed patch
Darin Adler
Comment 2
2011-06-07 11:41:34 PDT
Comment on
attachment 96270
[details]
proposed patch View in context:
https://bugs.webkit.org/attachment.cgi?id=96270&action=review
> Source/JavaScriptCore/ChangeLog:5 > + Make JSStaticFunction and JSStaticValue less "const"
Why?
Darin Adler
Comment 3
2011-06-07 11:42:33 PDT
Comment on
attachment 96270
[details]
proposed patch View in context:
https://bugs.webkit.org/attachment.cgi?id=96270&action=review
Seems OK to change this. The other data members aren’t const, and there’s no strong argument for making these const.
>> Source/JavaScriptCore/ChangeLog:5 >> + Make JSStaticFunction and JSStaticValue less "const" > > Why?
I think I see why now.
Geoffrey Garen
Comment 4
2011-06-07 14:56:52 PDT
Comment on
attachment 96270
[details]
proposed patch Marking cq+ to get this landed by the commit queue.
Geoffrey Garen
Comment 5
2011-06-07 14:59:58 PDT
Comment on
attachment 96270
[details]
proposed patch Oops! The Windows EWS bot failed to compile, and showing this warning, which illustrates a real bug in your code: 7>c:\cygwin\home\buildbot\webkit\source\javascriptcore\api\tests\testapi.c(943) : error C2220: warning treated as error - no 'object' file generated 7>c:\cygwin\home\buildbot\webkit\source\javascriptcore\api\tests\testapi.c(943) : warning C4700: uninitialized local variable 'fun' used 7>c:\cygwin\home\buildbot\webkit\source\javascriptcore\api\tests\testapi.c(945) : warning C4700: uninitialized local variable 'val' used You can't just declare "fun" as a pointer -- you need to point to something. I'd suggest changing this to declare fun and val as variables on the stack.
Juan C. Montemayor
Comment 6
2011-06-07 15:20:37 PDT
Created
attachment 96309
[details]
proposed patch sorry, didn't catch that in the original report. all fixed now :)
WebKit Review Bot
Comment 7
2011-06-07 19:00:44 PDT
Comment on
attachment 96309
[details]
proposed patch Clearing flags on attachment: 96309 Committed
r88313
: <
http://trac.webkit.org/changeset/88313
>
WebKit Review Bot
Comment 8
2011-06-07 19:00:48 PDT
All reviewed patches have been landed. Closing bug.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug