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

fdwrite.c: initialize pointers to NULL and a few other cleanups #1059

Closed
wants to merge 2 commits into from

Conversation

rilysh
Copy link
Contributor

@rilysh rilysh commented Jan 14, 2024

  1. Both trackbuf and vrfybuf are initialized to zero (NULL). While it's okay to initialize pointers to zero, to keep consistency, as they're explicitly pointers, it's better to just use NULL ((void *)0) instead of 0 (both are equivalent to the compilers).
  2. Call free() for both trackbuf and vrfybuf after their job has been done.
  3. Remove the register keyword. Compilers generally ignore this keyword (except for very very old compilers and CPUs).
  4. Remove the ctype.h header. It's not being used anywhere in the file.

1. Both trackbuf and vrfybuf are initialized to
zero (NULL). While it's okay to initialize pointers
to zero, to keep consistency, as they're explicitly
pointers, it's better to just use NULL ((void *)0)
instead of 0 (both are equivalent to the compilers).

2. Call free() for both trackbuf and vrfybuf after
their job has been done.

3. Remove the register keyword. Compilers generally
ignore this keyword (except for very very old compilers
and CPUs).

4. Remove the ctype.h header. It's not being used
anywhere in the file.

Signed-off-by: rilysh <nightquick@proton.me>
Copy link
Contributor

@igalic igalic left a comment

Choose a reason for hiding this comment

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

looks sensible 👍

@@ -26,7 +25,7 @@ format_track(int fd, int cyl, int secs, int head, int rate,
int gaplen, int secsize, int fill, int interleave)
{
struct fd_formb f;
register int i,j;
int i,j;
int il[100];

memset(il,0,sizeof il);
Copy link
Contributor

Choose a reason for hiding this comment

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

while you're already here, why not format this according to style(9).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I intentionally left it behind as style(9) also says to indent the first level with 8 characters (tabs) and running indent(1) drastically changes the indentation (which I wasn't sure about whether should I apply or not)...

I think for now I'll apply it for these (CI) warnings only. If full indentation is acceptable, then I will add that too.
CI Link: https://github.com/freebsd/freebsd-src/actions/runs/7517809483/job/20464384723?pr=1059

Signed-off-by: rilysh <nightquick@proton.me>
@bsdimp
Copy link
Member

bsdimp commented Jan 14, 2024

We have plans to remove floppy support soon. Not sure it is worth the effort

@rilysh
Copy link
Contributor Author

rilysh commented Jan 14, 2024

We have plans to remove floppy support soon. Not sure it is worth the effort

Whoops... I didn't know that, is there a current plan on which version of FreeBSD release floppy support will be stripped away? (e.g. the version, 14.0)

@igalic
Copy link
Contributor

igalic commented Jan 14, 2024

14.0 has sailed, so even tho i haven't seen it on the plan for 15.0, the fact that we're getting rid of 32 bit platforms (in the kernel) kind of hints at other things that might fall to the ax

@bsdimp
Copy link
Member

bsdimp commented Jan 14, 2024

14.0 has sailed, so even tho i haven't seen it on the plan for 15.0, the fact that we're getting rid of 32 bit platforms (in the kernel) kind of hints at other things that might fall to the ax

We've explicitly had fd on the list for a while. It won't be in 15. If we'd realized sooner, we'd have trimmed it for 14, but the trim list for that was already fairly large.

@bsdimp
Copy link
Member

bsdimp commented Apr 11, 2024

I went ahead and pushed this... Though in the future, a pull request like this would run into our new policy that say a change has to fix a real problem.

@bsdimp bsdimp closed this Apr 11, 2024
@bsdimp bsdimp added the merged label Apr 11, 2024
@bsdimp
Copy link
Member

bsdimp commented Apr 11, 2024

damn, I gotta update my landing scripts to properly credit... I just noticed @igalic approved, which should have added a reviewed by line.

freebsd-git pushed a commit that referenced this pull request Apr 11, 2024
1. Both trackbuf and vrfybuf are initialized to
zero (NULL). While it's okay to initialize pointers
to zero, to keep consistency, as they're explicitly
pointers, it's better to just use NULL ((void *)0)
instead of 0 (both are equivalent to the compilers).

2. Call free() for both trackbuf and vrfybuf after
their job has been done.

3. Remove the register keyword. Compilers generally
ignore this keyword (except for very very old compilers
and CPUs).

4. Remove the ctype.h header. It's not being used
anywhere in the file.

Signed-off-by: rilysh <nightquick@proton.me>
Reviewed by: imp
Pull Request: #1059
bsdjhb pushed a commit to bsdjhb/cheribsd that referenced this pull request Aug 7, 2024
1. Both trackbuf and vrfybuf are initialized to
zero (NULL). While it's okay to initialize pointers
to zero, to keep consistency, as they're explicitly
pointers, it's better to just use NULL ((void *)0)
instead of 0 (both are equivalent to the compilers).

2. Call free() for both trackbuf and vrfybuf after
their job has been done.

3. Remove the register keyword. Compilers generally
ignore this keyword (except for very very old compilers
and CPUs).

4. Remove the ctype.h header. It's not being used
anywhere in the file.

Signed-off-by: rilysh <nightquick@proton.me>
Reviewed by: imp
Pull Request: freebsd/freebsd-src#1059
bsdjhb pushed a commit to bsdjhb/cheribsd that referenced this pull request Aug 8, 2024
1. Both trackbuf and vrfybuf are initialized to
zero (NULL). While it's okay to initialize pointers
to zero, to keep consistency, as they're explicitly
pointers, it's better to just use NULL ((void *)0)
instead of 0 (both are equivalent to the compilers).

2. Call free() for both trackbuf and vrfybuf after
their job has been done.

3. Remove the register keyword. Compilers generally
ignore this keyword (except for very very old compilers
and CPUs).

4. Remove the ctype.h header. It's not being used
anywhere in the file.

Signed-off-by: rilysh <nightquick@proton.me>
Reviewed by: imp
Pull Request: freebsd/freebsd-src#1059
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants