-
Notifications
You must be signed in to change notification settings - Fork 6
Int cleanup #3
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
Open
johnnybubonic
wants to merge
1
commit into
g0rbe:master
Choose a base branch
from
johnnybubonic:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Int cleanup #3
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Fixes: * Inconsistent/incongruent use of int vs. int32; switched all to uint32 * Integer overflow due to using int32 instead of uint32 ** This allows `FS_RESERVED_FL` to be properly parsed
Author
|
(This will obviously break your API, but you only have one dep) |
devhaozi
reviewed
Nov 10, 2024
Comment on lines
+34
to
+60
| FS_SECRM_FL uint32 = 0x00000001 /* Secure deletion */ | ||
| FS_UNRM_FL = 0x00000002 /* Undelete */ | ||
| FS_COMPR_FL = 0x00000004 /* Compress file */ | ||
| FS_SYNC_FL = 0x00000008 /* Synchronous updates */ | ||
| FS_IMMUTABLE_FL = 0x00000010 /* Immutable file */ | ||
| FS_APPEND_FL = 0x00000020 /* writes to file may only append */ | ||
| FS_NODUMP_FL = 0x00000040 /* do not dump file */ | ||
| FS_NOATIME_FL = 0x00000080 /* do not update atime */ | ||
| FS_DIRTY_FL = 0x00000100 | ||
| FS_COMPRBLK_FL = 0x00000200 /* One or more compressed clusters */ | ||
| FS_NOCOMP_FL = 0x00000400 /* Don't compress */ | ||
| FS_ENCRYPT_FL = 0x00000800 /* Encrypted file */ | ||
| FS_BTREE_FL = 0x00001000 /* btree format dir */ | ||
| FS_INDEX_FL = 0x00001000 /* hash-indexed directory */ | ||
| FS_IMAGIC_FL = 0x00002000 /* AFS directory */ | ||
| FS_JOURNAL_DATA_FL = 0x00004000 /* Reserved for ext3 */ | ||
| FS_NOTAIL_FL = 0x00008000 /* file tail should not be merged */ | ||
| FS_DIRSYNC_FL = 0x00010000 /* dirsync behaviour (directories only) */ | ||
| FS_TOPDIR_FL = 0x00020000 /* Top of directory hierarchies*/ | ||
| FS_HUGE_FILE_FL = 0x00040000 /* Reserved for ext4 */ | ||
| FS_EXTENT_FL = 0x00080000 /* Extents */ | ||
| FS_EA_INODE_FL = 0x00200000 /* Inode used for large EA */ | ||
| FS_EOFBLOCKS_FL = 0x00400000 /* Reserved for ext4 */ | ||
| FS_NOCOW_FL = 0x00800000 /* Do not cow file */ | ||
| FS_INLINE_DATA_FL = 0x10000000 /* Reserved for ext4 */ | ||
| FS_PROJINHERIT_FL = 0x20000000 /* Create with parents projid */ | ||
| FS_RESERVED_FL = 0x80000000 /* reserved for ext2 lib */ |
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.
This is incorrect, it should be:
FS_SECRM_FL uint32 = 0x00000001 /* Secure deletion */
FS_UNRM_FL uint32 = 0x00000002 /* Undelete */
FS_COMPR_FL uint32 = 0x00000004 /* Compress file */
FS_SYNC_FL uint32 = 0x00000008 /* Synchronous updates */
FS_IMMUTABLE_FL uint32 = 0x00000010 /* Immutable file */
FS_APPEND_FL uint32 = 0x00000020 /* writes to file may only append */
FS_NODUMP_FL uint32 = 0x00000040 /* do not dump file */
FS_NOATIME_FL uint32 = 0x00000080 /* do not update atime */
FS_DIRTY_FL uint32 = 0x00000100
FS_COMPRBLK_FL uint32 = 0x00000200 /* One or more compressed clusters */
FS_NOCOMP_FL uint32 = 0x00000400 /* Don't compress */
FS_ENCRYPT_FL uint32 = 0x00000800 /* Encrypted file */
FS_BTREE_FL uint32 = 0x00001000 /* btree format dir */
FS_INDEX_FL uint32 = 0x00001000 /* hash-indexed directory */
FS_IMAGIC_FL uint32 = 0x00002000 /* AFS directory */
FS_JOURNAL_DATA_FL uint32 = 0x00004000 /* Reserved for ext3 */
FS_NOTAIL_FL uint32 = 0x00008000 /* file tail should not be merged */
FS_DIRSYNC_FL uint32 = 0x00010000 /* dirsync behaviour (directories only) */
FS_TOPDIR_FL uint32 = 0x00020000 /* Top of directory hierarchies*/
FS_HUGE_FILE_FL uint32 = 0x00040000 /* Reserved for ext4 */
FS_EXTENT_FL uint32 = 0x00080000 /* Extents */
FS_EA_INODE_FL uint32 = 0x00200000 /* Inode used for large EA */
FS_EOFBLOCKS_FL uint32 = 0x00400000 /* Reserved for ext4 */
FS_NOCOW_FL uint32 = 0x00800000 /* Do not cow file */
FS_INLINE_DATA_FL uint32 = 0x10000000 /* Reserved for ext4 */
FS_PROJINHERIT_FL uint32 = 0x20000000 /* Create with parents projid */
FS_RESERVED_FL uint32 = 0x80000000 /* reserved for ext2 lib */
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
So, a couple inconsistencies make this module a little irksome.
First, you defined ints for the const flags (since you don't declare what type they are), but the functions take int32s so an explicit conversion is necessary; an int cannot be automatically casted to an int32.
Secondly, you had an integer overflow by using the int32s.
chattr.FS_RESERVED_FLis defined as0x80000000, which is correct... but this is DEC2147483648.This is higher than Golang's int32 max by 1, which causes it to then overflow to
-2147483648.All of these are resolved by using uint32's everywhere.