Skip to content

Fix: use unsigned value to represent bytes #4493

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
wants to merge 2 commits into
base: devel
Choose a base branch
from

Conversation

ThalesBarretto
Copy link
Contributor

Some variables that represent bytes were found using a signed char type.

Before 3fb3bb5d38r, "configure: force 'char' type to be signed (#4025),
char types could be unsigned, depending on the platform, but now thery are signed.

This intoduces a rough edge on variables that relied on the "unsignedness" of the type char to represent bytes, without actually enforcing it.

This PR addresses that by enforcing the use of "unsigned" type in those cases.

	The forcing of signed char type was introduced by 3fb3bb5d38r,
"configure: force 'char' type to be signed (gluster#4025)".

	Thus at xlators/cluster/afr/src/afr-inode-write.c was found the
use of a char type to represent bytes, when it should be using an unsigned
type to avoid sign extension and overflow.

	This commit changes the variable "byte" to "unsigned" type.

Signed-off-by: Thales Antunes de Oliveira Barretto <[email protected]>
        The forcing of signed char type was introduced by 3fb3bb5d38r,
"configure: force 'char' type to be signed (gluster#4025)".

        Thus at xlators/features/compress/src/cdc-helper.c was found the
use of a char type to represent bytes, when it should be using an unsigned
type to avoid sign extension and overflow.

        This commit changes the variable "gzip_header" to "unsigned" type.

Signed-off-by: Thales Antunes de Oliveira Barretto <[email protected]>
@gluster-ant
Copy link
Collaborator

Can one of the admins verify this patch?

1 similar comment
@gluster-ant
Copy link
Collaborator

Can one of the admins verify this patch?

@gluster-ant
Copy link
Collaborator

CLANG-FORMAT FAILURE:
Before merging the patch, this diff needs to be considered for passing clang-format

index ec2ba9878..0f9d806b1 100644
--- a/xlators/features/compress/src/cdc-helper.c
+++ b/xlators/features/compress/src/cdc-helper.c
@@ -30,8 +30,8 @@
  * gzip_header is added only during debugging.
  * Refer to the function cdc_dump_iovec_to_disk
  */
-static const unsigned char gzip_header[10] = {'\037', '\213', Z_DEFLATED,  0, 0, 0, 0,
-                                     0,      0,      GF_CDC_OS_ID};
+static const unsigned char gzip_header[10] = {
+    '\037', '\213', Z_DEFLATED, 0, 0, 0, 0, 0, 0, GF_CDC_OS_ID};
 
 static int32_t
 cdc_next_iovec(cdc_info_t *ci)

@ThalesBarretto ThalesBarretto marked this pull request as ready for review March 11, 2025 02:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants