Uninitialized variable 'rv' returned in dosprintf in jsprf.cpp.

RESOLVED FIXED in mozilla35

Status

()

Core
JavaScript Engine
RESOLVED FIXED
3 years ago
3 years ago

People

(Reporter: arai, Assigned: gokcehankara)

Tracking

Trunk
mozilla35
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

3 years ago
dosprintf returns uninitialized variable 'rv'.

http://dxr.mozilla.org/mozilla-central/source/js/src/jsprf.cpp#621
>    if (!BuildArgArray(fmt, ap, nas)) {
>        // the fmt contains error Numbered Argument format, jliu@netscape.com
>        JS_ASSERT(0);
>        return rv;
>    }

It should be "return -1".
(Reporter)

Updated

3 years ago
Blocks: 1019838
(Assignee)

Comment 1

3 years ago
Looks like we missed that on the final version of the patch in the previous bug, sorry for that. We had talked about changing `dosprintf` and other functions here to return a `bool` instead of `int`. This could be done in this bug if it's appropriate. I'm already familiar with the code here so I can do it if noone else wants.
Flags: needinfo?(continuation)
(In reply to gokcehankara from comment #1)
> I'm already familiar with the code here so I
> can do it if noone else wants.

Sounds good to me, thanks.
Flags: needinfo?(continuation)
This bug is the last -Wuninitialized warning that clang and gcc report in mozilla-central. After it's fixed, I hope to enable -Wuninitialized warnings as errors in bug 1001975.
Blocks: 1001975
(Assignee)

Comment 4

3 years ago
I'm having a busy week at the moment, so I was hoping to take a look at this at the end of the week. If someone wants to take over it's fine by me. Alternatively, it might be easier to fix this bug simply with Tooru's suggestion (by changing `return rv;` to `return -1;`) and leave the refactoring to a different bug so that it won't block bug 1001975.
> This bug is the last -Wuninitialized warning that clang and gcc report in
> mozilla-central.

Oh, nice. I thought that making -Wuninitialized an error was a hopeless goal, but it looks like that's no longer the case.
(Assignee)

Comment 6

3 years ago
Created attachment 8495905 [details] [diff] [review]
1070689.patch - Change return type of dosprintf functions from int to bool (in jsprf.cpp)

I'm attaching a patch for changing the return type of functions in here (jsprf.cpp) from int (0 for success, -1 for failure) to bool (true for success, false for failure) except for public functions so they should work as before. This should fix this bug.

I haven't set anyone for review as I wasn't sure who to pick. Also I still don't have repo access so I'm gonna require some help with that either.
(Assignee)

Updated

3 years ago
Attachment #8495905 - Flags: review?(nicolas.b.pierron)
Comment on attachment 8495905 [details] [diff] [review]
1070689.patch - Change return type of dosprintf functions from int to bool (in jsprf.cpp)

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

Nice work.
Attachment #8495905 - Flags: review?(nicolas.b.pierron) → review+
https://treeherder.mozilla.org/ui/#/jobs?repo=try&revision=c27cabb2bf74
https://hg.mozilla.org/integration/mozilla-inbound/rev/7f08e93cc2a5
(Assignee)

Comment 9

3 years ago
Thank you Nicolas..
https://hg.mozilla.org/mozilla-central/rev/7f08e93cc2a5
Assignee: nobody → gokcehankara
Status: NEW → RESOLVED
Last Resolved: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla35
(In reply to gokcehankara from comment #9)
> Thank you Nicolas..

Do you know what you want to continue working on?
(Assignee)

Comment 12

3 years ago
(In reply to Nicolas B. Pierron [:nbp] from comment #11)
> (In reply to gokcehankara from comment #9)
> > Thank you Nicolas..
> 
> Do you know what you want to continue working on?

I don't have anything in mind so I'm open to suggestions if you have any. Since my school has started I would prefer something I could work on with a small pace.
(In reply to gokcehankara from comment #12)
> (In reply to Nicolas B. Pierron [:nbp] from comment #11)
> > Do you know what you want to continue working on?
> 
> I don't have anything in mind so I'm open to suggestions if you have any.
> Since my school has started I would prefer something I could work on with a
> small pace.

I have a few bugs such as Bug 1062893, which are not urgent but are adding more capabilities of optimization to IonMonkey.
Blocks: 1089997
You need to log in before you can comment on or make changes to this bug.