Skip to content

Commit

Permalink
s/==/===
Browse files Browse the repository at this point in the history
  • Loading branch information
copy committed Jul 13, 2024
1 parent 1e5783d commit d648e00
Show file tree
Hide file tree
Showing 13 changed files with 44 additions and 43 deletions.
1 change: 1 addition & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default [
"catch": { "after": false },
} }],
"semi": "error",
"eqeqeq": "error",
//"no-var": "error",
"radix": "error",
"comma-style": ["error", "last"],
Expand Down
18 changes: 9 additions & 9 deletions lib/9p.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ Virtio9p.prototype.ReceiveRequest = async function (bufchain) {
var idx = this.fids[fid].inodeid;
var inode = this.fs.GetInode(idx);
message.Debug("file open " + this.fids[fid].dbg_name);
//if (inode.status == STATUS_LOADING) return;
//if (inode.status === STATUS_LOADING) return;
var ret = this.fs.OpenInode(idx, mode);

this.fs.AddEvent(this.fids[fid].inodeid,
Expand Down Expand Up @@ -576,16 +576,16 @@ Virtio9p.prototype.ReceiveRequest = async function (bufchain) {
var offset = req[1];
var count = req[2];
var inode = this.fs.GetInode(this.fids[fid].inodeid);
if(id == 40) message.Debug("[treaddir]: fid=" + fid + " offset=" + offset + " count=" + count);
if(id == 116) message.Debug("[read]: fid=" + fid + " (" + this.fids[fid].dbg_name + ") offset=" + offset + " count=" + count + " fidtype=" + this.fids[fid].type);
if(id === 40) message.Debug("[treaddir]: fid=" + fid + " offset=" + offset + " count=" + count);
if(id === 116) message.Debug("[read]: fid=" + fid + " (" + this.fids[fid].dbg_name + ") offset=" + offset + " count=" + count + " fidtype=" + this.fids[fid].type);
if(!inode || inode.status === STATUS_UNLINKED)
{
message.Debug("read/treaddir: unlinked");
this.SendError(tag, "No such file or directory", ENOENT);
this.SendReply(bufchain);
break;
}
if(this.fids[fid].type == FID_XATTR) {
if(this.fids[fid].type === FID_XATTR) {
if(inode.caps.length < offset+count) count = inode.caps.length - offset;
for(var i=0; i<count; i++)
this.replybuffer[7+4+i] = inode.caps[offset+i];
Expand All @@ -599,7 +599,7 @@ Virtio9p.prototype.ReceiveRequest = async function (bufchain) {
count = Math.min(count, this.replybuffer.length - (7 + 4));

if(inode.size < offset+count) count = inode.size - offset;
else if(id == 40)
else if(id === 40)
{
// for directories, return whole number of dir-entries.
count = this.fs.RoundToDirentry(inodeid, offset + count) - offset;
Expand Down Expand Up @@ -693,7 +693,7 @@ Virtio9p.prototype.ReceiveRequest = async function (bufchain) {
var flags = req[2];
message.Debug("[unlink]: dirfd=" + dirfd + " name=" + name + " flags=" + flags);
var fid = this.fs.Search(this.fids[dirfd].inodeid, name);
if(fid == -1) {
if(fid === -1) {
this.SendError(tag, "No such file or directory", ENOENT);
this.SendReply(bufchain);
break;
Expand Down Expand Up @@ -759,7 +759,7 @@ Virtio9p.prototype.ReceiveRequest = async function (bufchain) {
var nwfid = req[1];
var nwname = req[2];
message.Debug("[walk]: fid=" + req[0] + " nwfid=" + req[1] + " nwname=" + nwname);
if(nwname == 0) {
if(nwname === 0) {
this.fids[nwfid] = this.Createfid(this.fids[fid].inodeid, FID_INODE, this.fids[fid].uid, this.fids[fid].dbg_name);
//this.fids[nwfid].inodeid = this.fids[fid].inodeid;
marshall.Marshall(["h"], [0], this.replybuffer, 7);
Expand All @@ -780,7 +780,7 @@ Virtio9p.prototype.ReceiveRequest = async function (bufchain) {
for(var i=0; i<nwname; i++) {
idx = this.fs.Search(idx, walk[i]);

if(idx == -1) {
if(idx === -1) {
message.Debug("Could not find: " + walk[i]);
break;
}
Expand Down Expand Up @@ -840,7 +840,7 @@ Virtio9p.prototype.ReceiveRequest = async function (bufchain) {
//this.fids[newfid].inodeid = this.fids[fid].inodeid;
//this.fids[newfid].type = FID_NONE;
var length = 0;
if (name == "security.capability") {
if (name === "security.capability") {
length = this.fs.PrepareCAPs(this.fids[fid].inodeid);
this.fids[newfid].type = FID_XATTR;
}
Expand Down
34 changes: 17 additions & 17 deletions lib/filesystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ FS.prototype.set_state = function(state)

FS.prototype.AddEvent = function(id, OnEvent) {
var inode = this.inodes[id];
if(inode.status == STATUS_OK || inode.status == STATUS_ON_STORAGE) {
if(inode.status === STATUS_OK || inode.status === STATUS_ON_STORAGE) {
OnEvent();
}
else if(this.is_forwarder(inode))
Expand All @@ -153,7 +153,7 @@ FS.prototype.HandleEvent = function(id) {
//message.Debug("number of events: " + this.events.length);
var newevents = [];
for(var i=0; i<this.events.length; i++) {
if(this.events[i].id == id) {
if(this.events[i].id === id) {
this.events[i].OnEvent();
} else {
newevents.push(this.events[i]);
Expand Down Expand Up @@ -326,13 +326,13 @@ FS.prototype.unlink_from_dir = function(parentid, name)
};

FS.prototype.PushInode = function(inode, parentid, name) {
if(parentid != -1) {
if(parentid !== -1) {
this.inodes.push(inode);
inode.fid = this.inodes.length - 1;
this.link_under_dir(parentid, inode.fid, name);
return;
} else {
if(this.inodes.length == 0) { // if root directory
if(this.inodes.length === 0) { // if root directory
this.inodes.push(inode);
inode.direntries.set(".", 0);
inode.direntries.set("..", 0);
Expand Down Expand Up @@ -696,7 +696,7 @@ FS.prototype.OpenInode = function(id, mode) {
{
return this.follow_fs(inode).OpenInode(inode.foreign_id, mode);
}
if((inode.mode&S_IFMT) == S_IFDIR) {
if((inode.mode&S_IFMT) === S_IFDIR) {
this.FillDirectory(id);
}
/*
Expand All @@ -723,7 +723,7 @@ FS.prototype.CloseInode = async function(id) {
{
this.storage.uncache(inode.sha256sum);
}
if(inode.status == STATUS_UNLINKED) {
if(inode.status === STATUS_UNLINKED) {
//message.Debug("Filesystem: Delete unlinked file");
inode.status = STATUS_INVALID;
await this.DeleteData(id);
Expand All @@ -735,7 +735,7 @@ FS.prototype.CloseInode = async function(id) {
*/
FS.prototype.Rename = async function(olddirid, oldname, newdirid, newname) {
// message.Debug("Rename " + oldname + " to " + newname);
if((olddirid == newdirid) && (oldname == newname)) {
if((olddirid === newdirid) && (oldname === newname)) {
return 0;
}
var oldid = this.Search(olddirid, oldname);
Expand All @@ -748,7 +748,7 @@ FS.prototype.Rename = async function(olddirid, oldname, newdirid, newname) {
var oldpath = this.GetFullPath(olddirid) + "/" + oldname;

var newid = this.Search(newdirid, newname);
if(newid != -1) {
if(newid !== -1) {
const ret = this.Unlink(newdirid, newname);
if(ret < 0) return ret;
}
Expand Down Expand Up @@ -986,7 +986,7 @@ FS.prototype.GetFullPath = function(idx) {

var path = "";

while(idx != 0) {
while(idx !== 0) {
path = "/" + this.GetDirectoryName(idx) + path;
idx = this.GetParent(idx);
}
Expand Down Expand Up @@ -1172,7 +1172,7 @@ FS.prototype.ChangeSize = async function(idx, newsize)
var inode = this.GetInode(idx);
var temp = await this.get_data(idx, 0, inode.size);
//message.Debug("change size to: " + newsize);
if(newsize == inode.size) return;
if(newsize === inode.size) return;
var data = new Uint8Array(newsize);
inode.size = newsize;
if(temp)
Expand Down Expand Up @@ -1201,7 +1201,7 @@ FS.prototype.SearchPath = function(path) {
{
forward_path = "/" + walk.slice(i).join("/");
}
if(id == -1) {
if(id === -1) {
if(i < n-1) return {id: -1, parentid: -1, name: walk[i], forward_path }; // one name of the path cannot be found
return {id: -1, parentid: parentid, name: walk[i], forward_path}; // the last element in the path does not exist, but the parent
}
Expand Down Expand Up @@ -1259,14 +1259,14 @@ FS.prototype.RecursiveDelete = function(path) {

FS.prototype.DeleteNode = function(path) {
var ids = this.SearchPath(path);
if(ids.id == -1) return;
if(ids.id === -1) return;

if((this.inodes[ids.id].mode&S_IFMT) == S_IFREG){
if((this.inodes[ids.id].mode&S_IFMT) === S_IFREG){
const ret = this.Unlink(ids.parentid, ids.name);
dbg_assert(ret === 0, "Filesystem DeleteNode failed with error code: " + (-ret));
return;
}
if((this.inodes[ids.id].mode&S_IFMT) == S_IFDIR){
if((this.inodes[ids.id].mode&S_IFMT) === S_IFDIR){
this.RecursiveDelete(path);
const ret = this.Unlink(ids.parentid, ids.name);
dbg_assert(ret === 0, "Filesystem DeleteNode failed with error code: " + (-ret));
Expand All @@ -1280,13 +1280,13 @@ FS.prototype.NotifyListeners = function(id, action, info) {
// info = {};

//var path = this.GetFullPath(id);
//if (this.watchFiles[path] == true && action=='write') {
//if (this.watchFiles[path] === true && action=='write') {
// message.Send("WatchFileEvent", path);
//}
//for (var directory of this.watchDirectories) {
// if (this.watchDirectories.hasOwnProperty(directory)) {
// var indexOf = path.indexOf(directory)
// if(indexOf == 0 || indexOf == 1)
// if(indexOf === 0 || indexOf === 1)
// message.Send("WatchDirectoryEvent", {path: path, event: action, info: info});
// }
//}
Expand All @@ -1296,7 +1296,7 @@ FS.prototype.NotifyListeners = function(id, action, info) {
FS.prototype.Check = function() {
for(var i=1; i<this.inodes.length; i++)
{
if(this.inodes[i].status == STATUS_INVALID) continue;
if(this.inodes[i].status === STATUS_INVALID) continue;

var inode = this.GetInode(i);
if(inode.nlinks < 0) {
Expand Down
4 changes: 2 additions & 2 deletions lib/jor1k.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ if(typeof XMLHttpRequest !== "undefined")
req.open("GET", url, true);
req.responseType = "arraybuffer";
req.onreadystatechange = function () {
if(req.readyState != 4) {
if(req.readyState !== 4) {
return;
}
if((req.status != 200) && (req.status != 0)) {
if((req.status !== 200) && (req.status !== 0)) {
OnError("Error: Could not load file " + url);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/marshall.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ marshall.Unmarshall = function(typelist, struct, state) {
var utf8converter = new UTF8StreamToUnicode();
for(var j=0; j < len; j++) {
var c = utf8converter.Put(struct[offset++]);
if(c == -1) continue;
if(c === -1) continue;
str += String.fromCharCode(c);
}
output.push(str);
Expand Down
4 changes: 2 additions & 2 deletions lib/utf8.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ function UTF8StreamToUnicode() {
break;

case 2:
if((this.stream[0]&0xE0) == 0xC0)
if((this.stream[1]&0xC0) == 0x80) {
if((this.stream[0]&0xE0) === 0xC0)
if((this.stream[1]&0xC0) === 0x80) {
this.ofs = 0;
return ((this.stream[0]&0x1F)<<6) | (this.stream[1]&0x3F);
}
Expand Down
6 changes: 3 additions & 3 deletions src/browser/print_stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ const print_stats = {

for(const { opcode, count } of counts)
{
if((opcode & 0xFF00) == 0x0F00)
if((opcode & 0xFF00) === 0x0F00)
{
per_opcode0f[opcode & 0xFF] += count;
}
Expand All @@ -250,7 +250,7 @@ const print_stats = {
{
text += i.toString(16).padStart(2, "0") + ":" + v86util.pads(Math.round(per_opcode[i] / factor), pad_length);

if(i % 16 == 15)
if(i % 16 === 15)
text += "\n";
else
text += " ";
Expand All @@ -263,7 +263,7 @@ const print_stats = {
{
text += (i & 0xFF).toString(16).padStart(2, "0") + ":" + v86util.pads(Math.round(per_opcode0f[i] / factor), pad_length);

if(i % 16 == 15)
if(i % 16 === 15)
text += "\n";
else
text += " ";
Expand Down
2 changes: 1 addition & 1 deletion src/sb16.js
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ SB16.prototype.port3x1_read = function()
SB16.prototype.port3x1_write = function(value)
{
dbg_log("331 write: mpu command: " + h(value), LOG_SB16);
if(value == 0xFF)
if(value === 0xFF)
{
// Command acknowledge.
this.mpu_read_buffer.clear();
Expand Down
2 changes: 1 addition & 1 deletion src/uart.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ function UART(cpu, port, bus)
var ret = this.iir & 0xF;
dbg_log("read interrupt identification: " + h(this.iir), LOG_SERIAL);

if(this.iir == UART_IIR_THRI) {
if(this.iir === UART_IIR_THRI) {
this.ClearInterrupt(UART_IIR_THRI);
}

Expand Down
2 changes: 1 addition & 1 deletion src/vga.js
Original file line number Diff line number Diff line change
Expand Up @@ -1827,7 +1827,7 @@ VGAScreen.prototype.port3D5_write = function(value)
var previous_vertical_display_enable_end = this.vertical_display_enable_end;
this.vertical_display_enable_end &= 0xFF;
this.vertical_display_enable_end |= (value << 3 & 0x200) | (value << 7 & 0x100);
if(previous_vertical_display_enable_end != this.vertical_display_enable_end)
if(previous_vertical_display_enable_end !== this.vertical_display_enable_end)
{
this.update_vga_size();
}
Expand Down
8 changes: 4 additions & 4 deletions src/virtio_console.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ function VirtioConsole(cpu, bus)
},
(queue_id) =>
{
if(queue_id != 2)
if(queue_id !== 2)
{
dbg_assert(false, "VirtioConsole Notified for wrong queue: " + queue_id +
" (expected queue_id of 2)");
Expand All @@ -113,7 +113,7 @@ function VirtioConsole(cpu, bus)
},
(queue_id) =>
{
if(queue_id != 3)
if(queue_id !== 3)
{
dbg_assert(false, "VirtioConsole Notified for wrong queue: " + queue_id +
" (expected queue_id of 3)");
Expand Down Expand Up @@ -151,7 +151,7 @@ function VirtioConsole(cpu, bus)
break;
case VIRTIO_CONSOLE_PORT_OPEN:
this.Ack(queue_id, bufchain);
if(port == 0) {
if(port === 0) {
this.SendWindowSize(port);
}
break;
Expand Down Expand Up @@ -204,7 +204,7 @@ function VirtioConsole(cpu, bus)
});

for(let port = 0; port < this.ports; ++port) {
const queue_id = port == 0 ? 0 : port * 2 + 2;
const queue_id = port === 0 ? 0 : port * 2 + 2;
this.bus.register("virtio-console" + port + "-input-bytes", function(data) {
const queue = this.virtio.queues[queue_id];
if(queue.has_request()) {
Expand Down
2 changes: 1 addition & 1 deletion tests/devices/virtio_9p.js
Original file line number Diff line number Diff line change
Expand Up @@ -1768,7 +1768,7 @@ function finish_tests()
emulator.stop();

console.log("\nTests finished.");
if(failed_tests.length == 0)
if(failed_tests.length === 0)
{
console.log("All tests passed");
}
Expand Down
2 changes: 1 addition & 1 deletion tests/nasm/rand.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function KISS07() {
var w = 14921776;
var c = 0;

if(args.length == 0) {
if(args.length === 0) {
args = [+new Date];
}
var mash = Mash();
Expand Down

0 comments on commit d648e00

Please sign in to comment.