Skip to content

Commit

Permalink
Remove unnecessary allowNull argument from getSocketAddress. NFC (#…
Browse files Browse the repository at this point in the history
…22643)

The only callsite that was using this third argument was simply doing
and early return, so we can just move the check to the caller and
simplify the code.
  • Loading branch information
sbc100 authored Sep 27, 2024
1 parent f508b43 commit b7c1126
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/library_syscall.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,11 +324,8 @@ var SyscallsLibrary = {
#endif
return socket;
},
/** @param {boolean=} allowNull */
$getSocketAddress__deps: ['$readSockaddr', '$FS', '$DNS'],
$getSocketAddress__docs: '/** @param {boolean=} allowNull */',
$getSocketAddress: (addrp, addrlen, allowNull) => {
if (allowNull && addrp === 0) return null;
$getSocketAddress: (addrp, addrlen) => {
var info = readSockaddr(addrp, addrlen);
if (info.errno) throw new FS.ErrnoError(info.errno);
info.addr = DNS.lookup_addr(info.addr) || info.addr;
Expand Down Expand Up @@ -421,11 +418,11 @@ var SyscallsLibrary = {
__syscall_sendto__deps: ['$getSocketFromFD', '$getSocketAddress'],
__syscall_sendto: (fd, message, length, flags, addr, addr_len) => {
var sock = getSocketFromFD(fd);
var dest = getSocketAddress(addr, addr_len, true);
if (!dest) {
if (!addr) {
// send, no address provided
return FS.write(sock.stream, HEAP8, message, length);
}
var dest = getSocketAddress(addr, addr_len);
// sendto an address
return sock.sock_ops.sendmsg(sock, HEAP8, message, length, dest.addr, dest.port);
},
Expand Down

0 comments on commit b7c1126

Please sign in to comment.