From 2f964aeddcf32c4b7b9788b292363c7e0237dd82 Mon Sep 17 00:00:00 2001 From: Martin Sajti Date: Tue, 29 Jul 2025 11:12:59 +0200 Subject: [PATCH] Fix invalid return statements Some return statement arguments are function calls, that has 'void' return type. The check for this is fixed, so the patch contains the fixes at the erroneous places. Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICNBX4 Internal issue: #19701 Change-Id: I4e871804c8513865c2958292f3ea2d5ef3e9593e Signed-off-by: Martin Sajti --- .../js/src/mod_fs/ani/ets/@ohos.file.fs.ets | 112 +++++++++--------- 1 file changed, 56 insertions(+), 56 deletions(-) diff --git a/interfaces/kits/js/src/mod_fs/ani/ets/@ohos.file.fs.ets b/interfaces/kits/js/src/mod_fs/ani/ets/@ohos.file.fs.ets index ee6be66d5..22dff2428 100644 --- a/interfaces/kits/js/src/mod_fs/ani/ets/@ohos.file.fs.ets +++ b/interfaces/kits/js/src/mod_fs/ani/ets/@ohos.file.fs.ets @@ -91,7 +91,7 @@ function accessSync(path: string, mode: AccessModeType, flag: AccessFlagType): b function close(file: int | File): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError) => void): void => { - let promise = taskpool.execute((file: int | File): undefined => FileIoImpl.closeSync(file), file); + let promise = taskpool.execute((file: int | File) => FileIoImpl.closeSync(file), file); promise.then((ret: NullishType): void => { resolve(undefined); }).catch((e: Error): void => { @@ -101,7 +101,7 @@ function close(file: int | File): Promise { } function close(file: int | File, callback: AsyncCallback): void { - let promise = taskpool.execute((file: int | File): undefined => FileIoImpl.closeSync(file), file); + let promise = taskpool.execute((file: int | File) => FileIoImpl.closeSync(file), file); promise.then((ret: NullishType): void => { let e = new BusinessError(); e.code = 0; @@ -167,7 +167,7 @@ function copyDirSync(src: string, dest: string, mode?: int): void { function copyDir(src: string, dest: string, mode?: int): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError>) => void): void => { - let promise = taskpool.execute((src: string, dest: string, mode?: int): undefined => + let promise = taskpool.execute((src: string, dest: string, mode?: int) => FileIoImpl.copyDirSync(src, dest, mode), src, dest, mode); promise.then((ret: NullishType): void => { resolve(undefined); @@ -178,7 +178,7 @@ function copyDir(src: string, dest: string, mode?: int): Promise { } function copyDir(src: string, dest: string, callback: AsyncCallback>): void { - let promise = taskpool.execute((src: string, dest: string): undefined => + let promise = taskpool.execute((src: string, dest: string) => FileIoImpl.copyDirSync(src, dest), src, dest); promise.then((ret: NullishType): void => { let e = new BusinessError>(); @@ -191,7 +191,7 @@ function copyDir(src: string, dest: string, callback: AsyncCallback>): void { - let promise = taskpool.execute((src: string, dest: string, mode: int): undefined => + let promise = taskpool.execute((src: string, dest: string, mode: int) => FileIoImpl.copyDirSync(src, dest, mode), src, dest, mode); promise.then((ret: NullishType): void => { let e = new BusinessError>(); @@ -234,7 +234,7 @@ function fdatasyncSync(fd: int): void { function fdatasync(fd: int): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError) => void): void => { - let promise = taskpool.execute((fd: int): undefined => FileIoImpl.fdatasyncSync(fd), fd); + let promise = taskpool.execute((fd: int) => FileIoImpl.fdatasyncSync(fd), fd); promise.then((ret: NullishType): void => { resolve(undefined); }).catch((e: Error): void => { @@ -244,7 +244,7 @@ function fdatasync(fd: int): Promise { } function fdatasync(fd: int, callback: AsyncCallback): void { - let promise = taskpool.execute((fd: int): undefined => FileIoImpl.fdatasyncSync(fd), fd); + let promise = taskpool.execute((fd: int) => FileIoImpl.fdatasyncSync(fd), fd); promise.then((ret: NullishType): void => { let e = new BusinessError(); e.code = 0; @@ -321,8 +321,8 @@ function moveDirSync(src: string, dest: string, mode?: int): void { function moveDir(src: string, dest: string, mode?: int): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError>) => void): void => { - let promise = taskpool.execute((src: string, dest: string, mode?: int): undefined => { - return FileIoImpl.movedirSync(src, dest, mode); + let promise = taskpool.execute((src: string, dest: string, mode?: int) => { + FileIoImpl.movedirSync(src, dest, mode); }, src, dest, mode); promise.then((ret: NullishType): void => { resolve(undefined); @@ -333,8 +333,8 @@ function moveDir(src: string, dest: string, mode?: int): Promise { } function moveDir(src: string, dest: string, callback: AsyncCallback>): void { - let promise = taskpool.execute((src: string, dest: string): undefined => { - return FileIoImpl.movedirSync(src, dest); + let promise = taskpool.execute((src: string, dest: string) => { + FileIoImpl.movedirSync(src, dest); }, src, dest); promise.then((ret: NullishType): void => { let e = new BusinessError>(); @@ -347,8 +347,8 @@ function moveDir(src: string, dest: string, callback: AsyncCallback>): void { - let promise = taskpool.execute((src: string, dest: string, mode: int): undefined => { - return FileIoImpl.movedirSync(src, dest, mode); + let promise = taskpool.execute((src: string, dest: string, mode: int) => { + FileIoImpl.movedirSync(src, dest, mode); }, src, dest, mode); promise.then((ret: NullishType): void => { let e = new BusinessError>(); @@ -419,8 +419,8 @@ function moveFileSync(src: string, dest: string, mode?: int): void { function moveFile(src: string, dest: string, mode?: int): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError) => void): void => { - let promise = taskpool.execute((src: string, dest: string, mode?: int): undefined => { - return FileIoImpl.moveFileSync(src, dest, mode); + let promise = taskpool.execute((src: string, dest: string, mode?: int) => { + FileIoImpl.moveFileSync(src, dest, mode); }, src, dest, mode); promise.then((ret: NullishType): void => { resolve(undefined); @@ -431,8 +431,8 @@ function moveFile(src: string, dest: string, mode?: int): Promise { } function moveFile(src: string, dest: string, mode: int, callback: AsyncCallback): void { - let promise = taskpool.execute((src: string, dest: string, mode: int): undefined => { - return FileIoImpl.moveFileSync(src, dest, mode); + let promise = taskpool.execute((src: string, dest: string, mode: int) => { + FileIoImpl.moveFileSync(src, dest, mode); }, src, dest, mode); promise.then((ret: NullishType): void => { let e = new BusinessError(); @@ -444,8 +444,8 @@ function moveFile(src: string, dest: string, mode: int, callback: AsyncCallback< } function moveFile(src: string, dest: string, callback: AsyncCallback): void { - let promise = taskpool.execute((src: string, dest: string): undefined => { - return FileIoImpl.moveFileSync(src, dest); + let promise = taskpool.execute((src: string, dest: string) => { + FileIoImpl.moveFileSync(src, dest); }, src, dest); promise.then((ret: NullishType): void => { let e = new BusinessError(); @@ -679,8 +679,8 @@ function truncateSync(file: string | int, len?: long): void { function truncate(file: string | int, len?: long): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError) => void): void => { - let promise = taskpool.execute((file: string | int, len?: long): undefined => { - return FileIoImpl.truncateSync(file, len); + let promise = taskpool.execute((file: string | int, len?: long) => { + FileIoImpl.truncateSync(file, len); }, file, len); promise.then((ret: NullishType): void => { resolve(undefined); @@ -691,8 +691,8 @@ function truncate(file: string | int, len?: long): Promise { } function truncate(file: string | int, callback: AsyncCallback): void { - let promise = taskpool.execute((file: string | int): undefined => { - return FileIoImpl.truncateSync(file); + let promise = taskpool.execute((file: string | int) => { + FileIoImpl.truncateSync(file); }, file); promise.then((ret: NullishType): void => { let e = new BusinessError(); @@ -704,8 +704,8 @@ function truncate(file: string | int, callback: AsyncCallback): void { } function truncate(file: string | int, len: long, callback: AsyncCallback): void { - let promise = taskpool.execute((file: string | int, len: long): undefined => { - return FileIoImpl.truncateSync(file, len); + let promise = taskpool.execute((file: string | int, len: long) => { + FileIoImpl.truncateSync(file, len); }, file, len); promise.then((ret: NullishType): void => { let e = new BusinessError(); @@ -723,7 +723,7 @@ function unlinkSync(path: string): void { function unlink(path: string): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError) => void): void => { - let promise = taskpool.execute((path: string): undefined => unlinkSync(path), path); + let promise = taskpool.execute((path: string) => unlinkSync(path), path); promise.then((ret: NullishType): void => { resolve(undefined); }).catch((e: Error): void => { @@ -733,7 +733,7 @@ function unlink(path: string): Promise { } function unlink(path: string, callback: AsyncCallback): void { - let promise = taskpool.execute((path: string): undefined => unlinkSync(path), path); + let promise = taskpool.execute((path: string) => unlinkSync(path), path); promise.then((ret: NullishType): void => { let e = new BusinessError(); e.code = 0; @@ -877,8 +877,8 @@ function fsyncSync(fd: int): void { function fsync(fd: int): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError) => void): void => { - let promise = taskpool.execute((fd: int): undefined => { - return FileIoImpl.fsyncSync(fd); + let promise = taskpool.execute((fd: int) => { + FileIoImpl.fsyncSync(fd); }, fd); promise.then((ret: NullishType): void => { resolve(undefined); @@ -889,8 +889,8 @@ function fsync(fd: int): Promise { } function fsync(fd: int, callback: AsyncCallback): void { - let promise = taskpool.execute((fd: int): undefined => { - return FileIoImpl.fsyncSync(fd); + let promise = taskpool.execute((fd: int) => { + FileIoImpl.fsyncSync(fd); }, fd); promise.then((ret: NullishType): void => { let e = new BusinessError(); @@ -908,8 +908,8 @@ function symlinkSync(target: string, srcPath: string): void { function symlink(target: string, srcPath: string): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError) => void): void => { - let promise = taskpool.execute((target: string, srcPath: string): undefined => { - return FileIoImpl.symlinkSync(target, srcPath); + let promise = taskpool.execute((target: string, srcPath: string) => { + FileIoImpl.symlinkSync(target, srcPath); }, target, srcPath); promise.then((ret: NullishType): void => { resolve(undefined); @@ -924,8 +924,8 @@ function renameSync(oldPath: string, newPath: string): void { function rename(oldPath: string, newPath: string): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError) => void): void => { - let promise = taskpool.execute((oldPath: string, newPath: string): undefined => { - return FileIoImpl.renameSync(oldPath, newPath); + let promise = taskpool.execute((oldPath: string, newPath: string) => { + FileIoImpl.renameSync(oldPath, newPath); }, oldPath, newPath); promise.then((ret: NullishType): void => { resolve(undefined); @@ -936,8 +936,8 @@ function rename(oldPath: string, newPath: string): Promise { } function rename(oldPath: string, newPath: string, callback: AsyncCallback): void { - let promise = taskpool.execute((oldPath: string, newPath: string): undefined => { - return FileIoImpl.renameSync(oldPath, newPath); + let promise = taskpool.execute((oldPath: string, newPath: string) => { + FileIoImpl.renameSync(oldPath, newPath); }, oldPath, newPath); promise.then((ret: NullishType): void => { let e = new BusinessError(); @@ -990,7 +990,7 @@ function setxattrSync(path: string, key: string, value: string): void { function setxattr(path: string, key: string, value: string): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError) => void): void => { - let promise = taskpool.execute((path: string, key: string, value: string): undefined => + let promise = taskpool.execute((path: string, key: string, value: string) => FileIoImpl.setxattrSync(path, key, value), path, key, value); promise.then((ret: NullishType): void => { resolve(undefined); @@ -1096,8 +1096,8 @@ function createWatcher(path: string, events: int, listener: WatchEventListener): } function symlink(target: string, srcPath: string, callback: AsyncCallback): void { - let promise = taskpool.execute((target: string, srcPath: string): undefined => { - return FileIoImpl.symlinkSync(target, srcPath); + let promise = taskpool.execute((target: string, srcPath: string) => { + FileIoImpl.symlinkSync(target, srcPath); }, target, srcPath); promise.then((ret: NullishType): void => { let e = new BusinessError(); @@ -1157,7 +1157,7 @@ function lstat(path: string, callback: AsyncCallback): void { } function copyFile(src: string | int, dest: string | int, mode?: int): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError) => void): void => { - let promise = taskpool.execute((src: string | int, dest: string | int, mode?: int): undefined => + let promise = taskpool.execute((src: string | int, dest: string | int, mode?: int) => FileIoImpl.copyFileSync(src, dest, mode), src, dest, mode); promise.then((ret: NullishType): void => { resolve(undefined); @@ -1169,7 +1169,7 @@ function copyFile(src: string | int, dest: string | int, mode?: int): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError) => void): void => { - let promise = taskpool.execute((srcUri: string, destUri: string, options?: CopyOptions): undefined => + let promise = taskpool.execute((srcUri: string, destUri: string, options?: CopyOptions) => FileIoImpl.copySync(srcUri, destUri, options), srcUri, destUri, options); promise.then((ret: NullishType): void => { resolve(undefined); @@ -1180,7 +1180,7 @@ function copy(srcUri: string, destUri: string, options?: CopyOptions): Promise): void { - let promise = taskpool.execute((src: string | int, dest: string | int, mode: int): undefined => + let promise = taskpool.execute((src: string | int, dest: string | int, mode: int) => FileIoImpl.copyFileSync(src, dest, mode), src, dest, mode); promise.then((ret: NullishType): void => { let e = new BusinessError(); @@ -1192,7 +1192,7 @@ function copyFile(src: string | int, dest: string | int, mode: int, callback: As } function copy(srcUri: string, destUri: string, options: CopyOptions, callback: AsyncCallback): void { - let promise = taskpool.execute((srcUri: string, destUri: string, options: CopyOptions): undefined => + let promise = taskpool.execute((srcUri: string, destUri: string, options: CopyOptions) => FileIoImpl.copySync(srcUri, destUri, options), srcUri, destUri, options); promise.then((ret: NullishType): void => { let e = new BusinessError(); @@ -1204,7 +1204,7 @@ function copy(srcUri: string, destUri: string, options: CopyOptions, callback: A } function copyFile(src: string | int, dest: string | int, callback: AsyncCallback): void { - let promise = taskpool.execute((src: string | int, dest: string | int): undefined => + let promise = taskpool.execute((src: string | int, dest: string | int) => FileIoImpl.copyFileSync(src, dest), src, dest); promise.then((ret: NullishType): void => { let e = new BusinessError(); @@ -1216,7 +1216,7 @@ function copyFile(src: string | int, dest: string | int, callback: AsyncCallback } function copy(srcUri: string, destUri: string, callback: AsyncCallback): void { - let promise = taskpool.execute((srcUri: string, destUri: string): undefined => + let promise = taskpool.execute((srcUri: string, destUri: string) => FileIoImpl.copySync(srcUri, destUri), srcUri, destUri); promise.then((ret: NullishType): void => { let e = new BusinessError(); @@ -1471,8 +1471,8 @@ export class FileInner implements File { lock(exclusive?: boolean): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError) => void): void => { - let promise = taskpool.execute((exclusive?: boolean): undefined => { - return this.lockSync(exclusive); + let promise = taskpool.execute((exclusive?: boolean) => { + this.lockSync(exclusive); }, exclusive); promise.then((ret: NullishType): void => { resolve(undefined); @@ -1483,8 +1483,8 @@ export class FileInner implements File { } lock(callback: AsyncCallback): void { - let promise = taskpool.execute((): undefined => { - return this.lockSync(); + let promise = taskpool.execute(() => { + this.lockSync(); }); promise.then((ret: NullishType): void => { let e = new BusinessError(); @@ -1496,8 +1496,8 @@ export class FileInner implements File { } lock(exclusive: boolean, callback: AsyncCallback): void { - let promise = taskpool.execute((exclusive: boolean): undefined => { - return this.lockSync(exclusive); + let promise = taskpool.execute((exclusive: boolean) => { + this.lockSync(exclusive); }, exclusive); promise.then((ret: NullishType): void => { let e = new BusinessError(); @@ -1631,7 +1631,7 @@ export class StreamInner implements Stream { close(): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError) => void): void => { - let promise = taskpool.execute((): undefined => this.closeSync()); + let promise = taskpool.execute(() => this.closeSync()); promise.then((ret: NullishType): void => { resolve(undefined); }).catch((e: Error): void => { @@ -1641,7 +1641,7 @@ export class StreamInner implements Stream { } close(callback: AsyncCallback): void { - let promise = taskpool.execute((): undefined => this.closeSync()); + let promise = taskpool.execute(() => this.closeSync()); promise.then((ret: NullishType): void => { let e = new BusinessError(); e.code = 0; @@ -1655,7 +1655,7 @@ export class StreamInner implements Stream { flush(): Promise { return new Promise((resolve: (result: undefined) => void, reject: (e: BusinessError) => void): void => { - let promise = taskpool.execute((): undefined => this.flushSync()); + let promise = taskpool.execute(() => this.flushSync()); promise.then((ret: NullishType): void => { resolve(undefined); }).catch((e: Error): void => { @@ -1665,7 +1665,7 @@ export class StreamInner implements Stream { } flush(callback: AsyncCallback): void { - let promise = taskpool.execute((): undefined => this.flushSync()); + let promise = taskpool.execute(() => this.flushSync()); promise.then((ret: NullishType): void => { let e = new BusinessError(); e.code = 0; -- Gitee