-
Notifications
You must be signed in to change notification settings - Fork 646
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes to support WASI on Zephyr #3948
base: dev/zephyr_file_socket
Are you sure you want to change the base?
Fixes to support WASI on Zephyr #3948
Conversation
Fixed issues in os_renameat Signed-off-by: Stephen Berard <[email protected]>
There is 1 testing failing above, but I don't believe it's related to this PR. |
It's not related. Don't be worried. |
|
||
char *path = strdup(new_path); | ||
if (path == NULL) { | ||
return __WASI_ENOMEM; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In before, if strdup()
returns NULL, ptr->path
will be set to old_path
instead of maintaining original value. But in after, it's not. So, is it on purpose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the idea is that if strdup fails, we return an error and do not perform the rename.
return __WASI_ENOMEM; | ||
} | ||
|
||
free(ptr->path); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just to be sure, IIUC, the core idea of this patch is to free(ptr->path)
before assigning a new value. Is that correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The core idea was to address the comments from @wenyongh (here)[https://github.com//pull/3633#discussion_r1732970108]. In the previous version, the strdup which was assigned directly to ptr->path without first freeing the old value. In this version, we strdup into a local variable and then do the free/rename if the operations succeed.
* To manage our file descriptors, we created a struct `zephyr_fs_desc` that | ||
* represent a zephyr file descriptor and hold useful informations. | ||
* We also created a file descriptor table to keep track of all the file | ||
* To manage our file descriptors, we a struct `zephyr_fs_desc` is created that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
had better remove we
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, fixed typo.
Fixed issues #3311.
@wenyongh I'm merging this to the branch created so that we can review and ensure all the items are addressed prior to merging back to main.