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

Prefer size_t over int where possible #415

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AtariDreams
Copy link
Contributor

This avoids needless truncation, which takes up multiple more instructions on some architectures, especially older ones.

@enaess
Copy link
Contributor

enaess commented Apr 23, 2023

These fixes look mostly good. Though, some cases the refactoring changes the structure ... Comments inline to for @paulusmack to review.

pppd/auth.c Outdated Show resolved Hide resolved
pppd/tls.c Show resolved Hide resolved
@paulusmack
Copy link
Collaborator

I have mixed feelings about these changes. It's reasonable to use size_t for things that are the length of a structure or a string, but I don't think that the savings in code size will be significant either in space or time. There's also a lot of changes spread out across the source tree which could be better as separate commits.

@AtariDreams
Copy link
Contributor Author

I have mixed feelings about these changes. It's reasonable to use size_t for things that are the length of a structure or a string, but I don't think that the savings in code size will be significant either in space or time. There's also a lot of changes spread out across the source tree which could be better as separate commits.

I think they would be best done at once, that's why, since they all have the same theme.

@Neustradamus
Copy link
Member

@AtariDreams: It is not possible to separate?

@Neustradamus
Copy link
Member

@AtariDreams: What is the solution?

@paulusmack
Copy link
Collaborator

I notice also that the signoff is a noreply.github.com address, which I don't consider adequate.

@Neustradamus
Copy link
Member

@AtariDreams: Have you seen the @paulusmack comment?
What is the situation with your signoff?

@Neustradamus Neustradamus added the Author Author answer is needed label Dec 21, 2023
@AtariDreams
Copy link
Contributor Author

@Neustradamus Fixed!

Copy link
Collaborator

@paulusmack paulusmack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general it seems like there is a bunch of refactoring here plus gratuitous whitespace changes, in addition to the changes mentioned in the commit description (i.e. converting int to size_t). So, at the very least the commit description needs to be more comprehensive. If nothing else it should identify any potential bugs fixed here, though in fact I would prefer the bug fixes to be in separate commits.

I'm not convinced by the rationale that we need to do this to reduce the generated code size. As far as I can see it is only going to reduce the code size on 64-bit machines, not 32-bit machines, some of which might arguably be a bit short on memory. If you have a 64-bit processor you probably have a GB or more of memory, and saving at most a few hundred bytes of instruction memory is going to be in the noise.

chat/chat.c Outdated Show resolved Hide resolved
chat/chat.c Outdated Show resolved Hide resolved
chat/chat.c Outdated Show resolved Hide resolved
pppd/chap.c Outdated Show resolved Hide resolved
chat/chat.c Show resolved Hide resolved
pppd/auth.c Outdated Show resolved Hide resolved
pppd/auth.c Show resolved Hide resolved
pppd/main.c Outdated Show resolved Hide resolved
@Neustradamus
Copy link
Member

@AtariDreams: Have you seen @paulusmack comments started:

Note: The other PR has been merged :)

@Neustradamus
Copy link
Member

@AtariDreams: Have you looked comments from @paulusmack?

@AtariDreams
Copy link
Contributor Author

I'll take a look.

@Neustradamus
Copy link
Member

@AtariDreams: Have you looked?
It will be good to have a solution before 2.5.1 release...

@paulusmack
Copy link
Collaborator

As far as I can see, there is no functional change here (or at least, none intended), so I am not going to wait for this.

This avoids needless truncation, which takes up multiple more instructions on some architectures, especially older ones.

Signed-off-by: Rose <gfunni234@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author Author answer is needed
Development

Successfully merging this pull request may close these issues.

None yet

4 participants