Don't throw warnings about octals in httpd module.

RESOLVED FIXED

Status

Add-on SDK
General
P2
normal
RESOLVED FIXED
6 years ago
6 years ago

People

(Reporter: KWierso, Assigned: KWierso)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 1 obsolete attachment)

(Assignee)

Description

6 years ago
Created attachment 575097 [details] [diff] [review]
s/0444/PR_RDONLY/

Starting sometime today, I started seeing warnings like this being logged when I was using the httpd module:

console: [JavaScript Warning: "octal literals and octal escape sequences are deprecated" {file: "res
ource://0bc0a5b2-5d3b-49dc-876b-fb296081070a-at-jetpack-api-utils-lib/cuddlefish.js -> resource://0b
c0a5b2-5d3b-49dc-876b-fb296081070a-at-jetpack-api-utils-lib/httpd.js" line: 2566 column: 53 source:
"      var fis = new FileInputStream(file, PR_RDONLY, 0444,
"}]

I wasn't seeing this before some today, but I'm not really sure why I'm seeing them now.

This patch makes the warnings go away, but I'm not sure if it's the right thing to do.

Attaching it now and requesting review on it, but I'd like some confirmation that other people are seeing the warnings too on a recent pull from github master. My steps to reproduce are to run "cfx test --filter test-request" from the addon-kit folder.
Attachment #575097 - Flags: review?(myk)
(Assignee)

Comment 1

6 years ago
(Also, PR_RDONLY is the same as 0444 permissions, right?)
(Assignee)

Updated

6 years ago
Priority: -- → P2
Comment on attachment 575097 [details] [diff] [review]
s/0444/PR_RDONLY/

(In reply to Wes Kocher (:KWierso) (Jetpack Bugmaster) from comment #1)
> (Also, PR_RDONLY is the same as 0444 permissions, right?)

No, PR_RDONLY is 0x01 <http://mxr.mozilla.org/mozilla-central/source/nsprpub/pr/include/prio.h#616>.

FileInputStream creates an nsIFileInputStream and calls its `init` method <http://mxr.mozilla.org/mozilla-central/source/netwerk/base/public/nsIFileStreams.idl>, whose `perm` argument takes file mode bits as described in prio.h <http://mxr.mozilla.org/mozilla-central/source/nsprpub/pr/include/prio.h#626>.

We could convert these numbers to decimal (292) or hexadecimal (0x124), but they're most readable as octals, so let's use `parseInt` to represent them as such while avoiding the warning:

    parseInt("444", 8)
Attachment #575097 - Flags: review?(myk) → review-
(Assignee)

Comment 3

6 years ago
Created attachment 576357 [details] [diff] [review]
parseInt("444", 8)

So, like this?
Attachment #575097 - Attachment is obsolete: true
Attachment #576357 - Flags: review?(myk)
Comment on attachment 576357 [details] [diff] [review]
parseInt("444", 8)

Exactly.
Attachment #576357 - Flags: review?(myk) → review+

Comment 5

6 years ago
Commit pushed to https://github.com/mozilla/addon-sdk

https://github.com/mozilla/addon-sdk/commit/ad778b71bfd62ce2219d5d419d727aaa59ed2f0d
fix bug 703195 - httpd module tests throw warnings about octals - replace deprecated octal literals with parseInt(octal, 8) calls; r=myk

Updated

6 years ago
Status: NEW → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED
Assignee: nobody → kwierso
You need to log in before you can comment on or make changes to this bug.