Skip to content
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

Optimize swab so that it can take any ssize_t value #516

Closed
wants to merge 1 commit into from

Conversation

RSilicon
Copy link
Contributor

Casting to int cuts off data on some platforms, resulting in the incorrect results for swab.

@emaste
Copy link
Member

emaste commented Jul 26, 2021

CI builds are currently broken due to 6cafdee

@RSilicon RSilicon changed the title Optimize swab so that I can take any ssize_t value Optimize swab so that it can take any ssize_t value Jul 29, 2021
@RSilicon RSilicon force-pushed the patch-19 branch 3 times, most recently from 26318ae to d0263ee Compare July 31, 2021 22:43
@RSilicon RSilicon force-pushed the patch-19 branch 2 times, most recently from ca93600 to 65ea569 Compare August 22, 2021 18:54
@RSilicon RSilicon force-pushed the patch-19 branch 5 times, most recently from d4ba7fd to cf69012 Compare August 24, 2021 21:58
@RSilicon RSilicon force-pushed the patch-19 branch 3 times, most recently from ec0d32d to 9a76db3 Compare October 4, 2021 17:53
Casting to int cuts off data on some platforms, resulting in the incorrect results for swab.
@bsdimp
Copy link
Member

bsdimp commented Feb 5, 2023

Pushed with tweaked commit message, documenting all the changes more fully.
70164d9

@bsdimp bsdimp closed this Feb 5, 2023
freebsd-git pushed a commit that referenced this pull request Feb 5, 2023
Casting to int truncates size on some platforms, resulting swab not
copying all the data. Cast len to size_t to avoid right shifting a
signed value: we know here it's > 0, so we can safely cast it w/o losing
precision.

In addition, be more careful with signedness of char pointers and
temporaries. Downgrade tmp from unsigned long to unsigned char since
we're only reading and writing characters.

Reviewed by: imp
Pull Request: #516
@RSilicon RSilicon deleted the patch-19 branch February 5, 2023 15:36
bsdjhb pushed a commit to bsdjhb/cheribsd that referenced this pull request Mar 22, 2023
Casting to int truncates size on some platforms, resulting swab not
copying all the data. Cast len to size_t to avoid right shifting a
signed value: we know here it's > 0, so we can safely cast it w/o losing
precision.

In addition, be more careful with signedness of char pointers and
temporaries. Downgrade tmp from unsigned long to unsigned char since
we're only reading and writing characters.

Reviewed by: imp
Pull Request: freebsd/freebsd-src#516
@emaste emaste added the merged label Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants