Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/lib/libasync.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ addToLibrary({
#endif
if (Asyncify.currData &&
Asyncify.state === Asyncify.State.Unwinding &&
Asyncify.exportCallStack.length === 0) {
!Asyncify.exportCallStack.length) {
// We just finished unwinding.
// Be sure to set the state before calling any other functions to avoid
// possible infinite recursion here (For example in debug pthread builds
Expand Down Expand Up @@ -548,7 +548,7 @@ addToLibrary({

var entryPoint = {{{ makeGetValue('newFiber', C_STRUCTS.emscripten_fiber_s.entry, '*') }}};

if (entryPoint !== 0) {
if (entryPoint) {
#if STACK_OVERFLOW_CHECK
writeStackCookie();
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/lib/libbootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
assert(false, 'libbootstrap.js only designed for use with BOOTSTRAPPING_STRUCT_INFO')
#endif

assert(Object.keys(LibraryManager.library).length === 0);
assert(!Object.keys(LibraryManager.library).length);
addToLibrary({
$callRuntimeCallbacks: () => {},

Expand Down
6 changes: 3 additions & 3 deletions src/lib/libbrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ var LibraryBrowser = {
var ret = '';
var leftchar = 0;
var leftbits = 0;
for (var i = 0; i < data.length; i++) {
leftchar = (leftchar << 8) | data[i];
for (var byte of data) {
leftchar = (leftchar << 8) | byte;
leftbits += 8;
while (leftbits >= 6) {
var curr = (leftchar >> (leftbits-6)) & 0x3f;
Expand Down Expand Up @@ -601,7 +601,7 @@ var LibraryBrowser = {
}
#endif
#if ASSERTIONS
assert(runDependencies === 0, 'async_load_script must be run when no other dependencies are active');
assert(!runDependencies, 'async_load_script must be run when no other dependencies are active');
#endif
{{{ runtimeKeepalivePush() }}}

Expand Down
4 changes: 2 additions & 2 deletions src/lib/libccall.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ addToLibrary({
for (var i = 0; i < args.length; i++) {
var converter = toC[argTypes[i]];
if (converter) {
if (stack === 0) stack = stackSave();
if (!stack) stack = stackSave();
cArgs[i] = converter(args[i]);
} else {
cArgs[i] = args[i];
Expand All @@ -86,7 +86,7 @@ addToLibrary({
#if ASYNCIFY == 1
runtimeKeepalivePop();
#endif
if (stack !== 0) stackRestore(stack);
if (stack) stackRestore(stack);
return convertReturnValue(ret);
}
#if ASYNCIFY
Expand Down
33 changes: 18 additions & 15 deletions src/lib/libcore.js
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,10 @@ addToLibrary({
var v4part = '';
// check if the 10 high-order bytes are all zeros (first 5 words)
for (i = 0; i < 5; i++) {
if (parts[i] !== 0) { hasipv4 = false; break; }
if (parts[i]) {
hasipv4 = false;
break;
}
}

if (hasipv4) {
Expand All @@ -777,7 +780,7 @@ addToLibrary({
return str;
}
// IPv4-compatible IPv6 address if 16-bit value (bytes 11 and 12) == 0x0000 (6th word)
if (parts[5] === 0) {
if (!parts[5]) {
str = '::';
// special case IPv6 addresses
if (v4part === '0.0.0.0') v4part = ''; // any/unspecified address
Expand All @@ -791,7 +794,7 @@ addToLibrary({

// first run to find the longest contiguous zero words
for (word = 0; word < 8; word++) {
if (parts[word] === 0) {
if (!parts[word]) {
if (word - lastzero > 1) {
len = 0;
}
Expand All @@ -807,10 +810,10 @@ addToLibrary({
for (word = 0; word < 8; word++) {
if (longest > 1) {
// compress contiguous zeros - to produce '::'
if (parts[word] === 0 && word >= zstart && word < (zstart + longest) ) {
if (!parts[word] && word >= zstart && word < (zstart + longest) ) {
if (word === zstart) {
str += ':';
if (zstart === 0) str += ':'; //leading zeros case
if (!zstart) str += ':'; //leading zeros case
}
continue;
}
Expand Down Expand Up @@ -844,7 +847,7 @@ addToLibrary({
var pathLen = salen - {{{ C_STRUCTS.sockaddr_un.sun_path }}};
var path = '';
if (pathLen > 0) {
if (HEAPU8[pathStart] === 0) {
if (!HEAPU8[pathStart]) {
path = '\0' + UTF8ToString(pathStart + 1, pathLen - 1, /*ignoreNul=*/true);
} else {
// A pathname address is NUL-terminated; stop at the first NUL.
Expand Down Expand Up @@ -894,7 +897,7 @@ addToLibrary({
// terminator), any other path is written NUL-terminated. An empty path
// is the unnamed address (family only).
addr ||= '';
var abstract = addr.charCodeAt(0) === 0;
var abstract = !addr.charCodeAt(0);
// Pathname addresses include the trailing NUL in the reported length;
// abstract addresses do not; an empty address is family-only (unnamed).
var bytes = addr ? lengthBytesUTF8(addr) + (abstract ? 0 : 1) : 0;
Expand Down Expand Up @@ -1067,10 +1070,10 @@ addToLibrary({

// If type or proto are set to zero in hints we should really be returning multiple addrinfo values, but for
// now default to a TCP STREAM socket so we can at least return a sensible addrinfo given NULL hints.
if (proto === 0) {
if (!proto) {
proto = {{{ cDefs.IPPROTO_TCP }}};
}
if (type === 0) {
if (!type) {
type = {{{ cDefs.SOCK_STREAM }}};
}

Expand All @@ -1081,14 +1084,14 @@ addToLibrary({
{{{ cDefs.AI_NUMERICSERV }}}|{{{ cDefs.AI_V4MAPPED }}}|{{{ cDefs.AI_ALL }}}|{{{ cDefs.AI_ADDRCONFIG }}})) {
return {{{ cDefs.EAI_BADFLAGS }}};
}
if (hint !== 0 && ({{{ makeGetValue('hint', C_STRUCTS.addrinfo.ai_flags, 'i32') }}} & {{{ cDefs.AI_CANONNAME }}}) && !node) {
if (hint && ({{{ makeGetValue('hint', C_STRUCTS.addrinfo.ai_flags, 'i32') }}} & {{{ cDefs.AI_CANONNAME }}}) && !node) {
return {{{ cDefs.EAI_BADFLAGS }}};
}
if (flags & {{{ cDefs.AI_ADDRCONFIG }}}) {
// TODO
return {{{ cDefs.EAI_NONAME }}};
}
if (type !== 0 && type !== {{{ cDefs.SOCK_STREAM }}} && type !== {{{ cDefs.SOCK_DGRAM }}}) {
if (type && type !== {{{ cDefs.SOCK_STREAM }}} && type !== {{{ cDefs.SOCK_DGRAM }}}) {
return {{{ cDefs.EAI_SOCKTYPE }}};
}
if (family !== {{{ cDefs.AF_UNSPEC }}} && family !== {{{ cDefs.AF_INET }}} && family !== {{{ cDefs.AF_INET6 }}}) {
Expand All @@ -1113,7 +1116,7 @@ addToLibrary({
if (family === {{{ cDefs.AF_UNSPEC }}}) {
family = {{{ cDefs.AF_INET }}};
}
if ((flags & {{{ cDefs.AI_PASSIVE }}}) === 0) {
if (!(flags & {{{ cDefs.AI_PASSIVE }}})) {
if (family === {{{ cDefs.AF_INET }}}) {
addr = _htonl({{{ cDefs.INADDR_LOOPBACK }}});
} else {
Expand Down Expand Up @@ -1263,7 +1266,7 @@ addToLibrary({
// to add extra entries from /etc/protocols if desired - though not sure if that'd actually be useful.
var list = Protocols.list;
var map = Protocols.map;
if (list.length === 0) {
if (!list.length) {
var entry = allocprotoent('tcp', 6, ['TCP']);
list.push(entry);
map['tcp'] = map['6'] = entry;
Expand Down Expand Up @@ -1739,7 +1742,7 @@ addToLibrary({
var parts = trace.split('\n');
for (var i = 0; i < parts.length; i++) {
var ret = {{{ makeDynCall('iii', 'func') }}}(0, arg);
if (ret !== 0) return;
if (ret) return;
}
},

Expand Down Expand Up @@ -2364,7 +2367,7 @@ addToLibrary({
assert(id, 'addRunDependency requires an ID')
assert(!runDependencyTracking[id]);
runDependencyTracking[id] = 1;
if (runDependencyWatcher === null && globalThis.setInterval) {
if (!runDependencyWatcher && globalThis.setInterval) {
// Check for missing dependencies every few seconds
runDependencyWatcher = setInterval(() => {
if (ABORT) {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/libdylink.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ var LibraryDylink = {

if (binary instanceof WebAssembly.Module) {
var dylinkSection = WebAssembly.Module.customSections(binary, 'dylink.0');
failIf(dylinkSection.length === 0, 'need dylink section');
failIf(!dylinkSection.length, 'need dylink section');
binary = new Uint8Array(dylinkSection[0]);
end = binary.length
} else {
Expand All @@ -490,7 +490,7 @@ var LibraryDylink = {
#endif
failIf(!magicNumberFound, 'need to see wasm magic number'); // \0asm
// we should see the dylink custom section right after the magic number and wasm version
failIf(binary[8] !== 0, 'need the dylink section to be first')
failIf(binary[8], 'need the dylink section to be first')
offset = 9;
var section_size = getLEB(); // section size
end = offset + section_size;
Expand Down
4 changes: 2 additions & 2 deletions src/lib/libembind_gen.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ var LibraryEmbind = {
out.push(' value: T;\n}\n');
}
out.push(`export type ${this.name} = `);
if (this.items.length === 0) {
if (!this.items.length) {
out.push('never/* Empty Enumerator */');
} else {
const outItems = [];
Expand Down Expand Up @@ -715,7 +715,7 @@ var LibraryEmbind = {
setter,
setterContext) {
fieldName = AsciiToString(fieldName);
const readonly = setter === 0;
const readonly = !setter;
if (!(readonly || getterReturnType === setterArgumentType)) {
throw new error('Mismatched getter and setter types are not supported.');
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/libembind_shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ var LibraryEmbindShared = {

$getEnumValueType(rawValueType) {
// This must match the values of enum_value_type in wire.h
return rawValueType === 0 ? 'object' : (rawValueType === 1 ? 'number' : 'string');
return !rawValueType ? 'object' : (rawValueType === 1 ? 'number' : 'string');
},

$getRequiredArgCount(argTypes) {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/libeventloop.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ LibraryJSEventLoop = {
fakeRequestAnimationFrame(func) {
// try to keep 60fps between calls to here
var now = Date.now();
if (MainLoop.nextRAF === 0) {
if (!MainLoop.nextRAF) {
MainLoop.nextRAF = now + 1000/60;
} else {
while (now + 2 >= MainLoop.nextRAF) { // fudge a little, to avoid timer jitter causing us to do lots of delay:0
Expand Down
2 changes: 1 addition & 1 deletion src/lib/libexceptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ var LibraryExceptions = {
// type of the thrown object. Find one which matches, and
// return the type of the catch block which should be called.
for (var caughtType of args) {
if (caughtType === 0 || caughtType === thrownType) {
if (!caughtType || caughtType === thrownType) {
// Catch all clause matched or exactly the same type is caught
break;
}
Expand Down
8 changes: 4 additions & 4 deletions src/lib/libfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -1384,8 +1384,8 @@ FS.staticInit();`;
// to write to file opened in read-only mode with MAP_PRIVATE flag,
// as all modifications will be visible only in the memory of
// the current process.
if ((prot & {{{ cDefs.PROT_WRITE }}}) !== 0
&& (flags & {{{ cDefs.MAP_PRIVATE}}}) === 0
if ((prot & {{{ cDefs.PROT_WRITE }}})
&& !(flags & {{{ cDefs.MAP_PRIVATE}}})
&& (stream.flags & {{{ cDefs.O_ACCMODE }}}) !== {{{ cDefs.O_RDWR}}}) {
throw new FS.ErrnoError({{{ cDefs.EACCES }}});
}
Expand Down Expand Up @@ -1487,7 +1487,7 @@ FS.staticInit();`;
// use a buffer to avoid overhead of individual crypto calls per byte
var randomBuffer = new Uint8Array(1024), randomLeft = 0;
var randomByte = () => {
if (randomLeft === 0) {
if (!randomLeft) {
randomFill(randomBuffer);
randomLeft = randomBuffer.byteLength;
}
Expand Down Expand Up @@ -1734,7 +1734,7 @@ FS.staticInit();`;
} catch (e) {
throw new FS.ErrnoError({{{ cDefs.EIO }}});
}
if (result === undefined && bytesRead === 0) {
if (result === undefined && !bytesRead) {
throw new FS.ErrnoError({{{ cDefs.EAGAIN }}});
}
if (result === null || result === undefined) break;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/libglemu.js
Original file line number Diff line number Diff line change
Expand Up @@ -2474,7 +2474,7 @@ var LibraryGLEmulation = {
this.hasNormal = GLImmediate.enabledClientAttributes[GLImmediate.NORMAL] &&
GLImmediate.clientAttributes[GLImmediate.NORMAL].size > 0 &&
this.normalLocation >= 0;
this.hasColor = (this.colorLocation === 0) || this.colorLocation > 0;
this.hasColor = this.colorLocation >= 0;

this.floatType = GLctx.FLOAT; // minor optimization

Expand Down
4 changes: 2 additions & 2 deletions src/lib/libhtml5.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ var LibraryHTML5 = {
function arraysHaveEqualContent(arrA, arrB) {
if (arrA.length != arrB.length) return false;

for (var i in arrA) {
for (var i = 0; i < arrA.length; i++) {
if (arrA[i] != arrB[i]) return false;
}
return true;
Expand Down Expand Up @@ -2140,7 +2140,7 @@ var LibraryHTML5 = {
if (canvas.GLctxObject?.GLctx) {
var prevViewport = canvas.GLctxObject.GLctx.getParameter(0xBA2 /* GL_VIEWPORT */);
// TODO: Perhaps autoResizeViewport should only be true if FBO 0 is currently active?
autoResizeViewport = (prevViewport[0] === 0 && prevViewport[1] === 0 && prevViewport[2] === canvas.width && prevViewport[3] === canvas.height);
autoResizeViewport = (!prevViewport[0] && !prevViewport[1] && prevViewport[2] === canvas.width && prevViewport[3] === canvas.height);
#if GL_DEBUG
dbg(`Resizing canvas from ${canvas.width}x${canvas.height} to ${width}x${height}. Previous GL viewport size was ${prevViewport}, so autoResizeViewport=${autoResizeViewport}`);
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/lib/libmemfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,11 +282,11 @@ addToLibrary({

if (canOwn) {
#if ASSERTIONS
assert(position === 0, 'canOwn must imply no weird position inside the file');
assert(!position, 'canOwn must imply no weird position inside the file');
#endif
node.contents = buffer.subarray(offset, offset + length);
node.usedBytes = length;
} else if (node.usedBytes === 0 && position === 0) { // If this is a simple first write to an empty file, do a fast set since we don't need to care about old data.
} else if (!node.usedBytes && !position) { // If this is a simple first write to an empty file, do a fast set since we don't need to care about old data.
node.contents = buffer.slice(offset, offset + length);
node.usedBytes = length;
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/libnodefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ addToLibrary({
},
close(stream) {
NODEFS.tryFSOperation(() => {
if (stream.nfd && --stream.shared.refcount === 0) {
if (stream.nfd && !--stream.shared.refcount) {
fs.closeSync(stream.nfd);
}
});
Expand Down
6 changes: 3 additions & 3 deletions src/lib/libpipefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,17 +280,17 @@ addToLibrary({
// When the last write end closes, wake any poll/epoll waiter on the read
// end with POLLHUP so a reader blocked on the writer dropping unblocks.
if ((stream.flags & {{{ cDefs.O_ACCMODE }}}) === {{{ cDefs.O_WRONLY }}}) {
if (--pipe.writerCount === 0) {
if (!--pipe.writerCount) {
pipe.writeClosed = true;
pipe.readNode.notifyListeners({{{ cDefs.POLLHUP }}} | {{{ cDefs.POLLRDNORM }}} | {{{ cDefs.POLLIN }}});
}
} else if (--pipe.readerCount === 0) {
} else if (!--pipe.readerCount) {
// Mirror: when the last read end closes, wake any poll/epoll waiter on
// the write end with POLLERR (a further write would get EPIPE).
pipe.readClosed = true;
pipe.writeNode.notifyListeners({{{ cDefs.POLLERR }}} | {{{ cDefs.POLLWRNORM }}} | {{{ cDefs.POLLOUT }}});
}
if (pipe.readerCount === 0 && pipe.writerCount === 0) {
if (!pipe.readerCount && !pipe.writerCount) {
pipe.buckets = null;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/lib/libpthread.js
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,7 @@ var LibraryPThread = {
// Synchronously proxy the thread creation to main thread if possible. If we
// need to transfer ownership of objects, then proxy asynchronously via
// postMessage.
if (ENVIRONMENT_IS_PTHREAD && (transferList.length === 0 || error)) {
if (ENVIRONMENT_IS_PTHREAD && (!transferList.length || error)) {
return pthreadCreateProxied(pthread_ptr, attr, startRoutine, arg);
}

Expand Down Expand Up @@ -1232,7 +1232,7 @@ var LibraryPThread = {
#endif
#if ASSERTIONS
assert(!ENVIRONMENT_IS_PTHREAD, 'dlsyncThreadsAsync() should only be called from the main thread');
assert(Object.keys(PThread.outstandingPromises).length === 0);
assert(!Object.keys(PThread.outstandingPromises).length);
#endif

const promises = [];
Expand Down
Loading
Loading