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

fix all -Wdeprecated-non-prototype warnings #702

Closed
rosasco-wk opened this issue Sep 7, 2022 · 7 comments
Closed

fix all -Wdeprecated-non-prototype warnings #702

rosasco-wk opened this issue Sep 7, 2022 · 7 comments

Comments

@rosasco-wk
Copy link

I'd like to fix all the compiler warnings in Zlib that result from the -Wdeprecated-non-prototype flag.

Compiler

~/src/zlib (master)  > ${FUCHSIA_DIR}/./prebuilt/third_party/clang/linux-x64/bin/clang --version                                                                                                                [10:42:08]
Fuchsia clang version 16.0.0 (https://llvm.googlesource.com/llvm-project 039b969b32b64b64123dce30dd28ec4e343d893f)
Target: x86_64-unknown-linux-gnu
Thread model: posix

Output

Warnings generated by issuing make test are attached.

deprecated.txt

Suggested Style

In its current form, the code uses separate type declaration lines including a comment e.g.:
unsigned dist; /* distance of matched string */

Moving the type unsigned into the declaration alone leaves the comment that follows unaccounted for.

Below is a suggested example diff for how to get rid of the deprecation warnings and retain the comments:

~/src/zlib (master)  > git diff trees.c                                                                                                                                                                         [10:45:32]
diff --git a/trees.c b/trees.c
index f73fd99..9e4e358 100644
--- a/trees.c
+++ b/trees.c
@@ -1011,11 +1011,11 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
 /* ===========================================================================
  * Save the match info and tally the frequency counts. Return true if
  * the current block must be flushed.
+ *
+ * |dist| - distance of matched string
+ * |lc|   - match length-MIN_MATCH or unmatched char (if dist==0)
  */
-int ZLIB_INTERNAL _tr_tally (s, dist, lc)
-    deflate_state *s;
-    unsigned dist;  /* distance of matched string */
-    unsigned lc;    /* match length-MIN_MATCH or unmatched char (if dist==0) */
+int ZLIB_INTERNAL _tr_tally (deflate_state *s, unsigned dist, unsigned lc)
 {
     s->sym_buf[s->sym_next++] = dist;
     s->sym_buf[s->sym_next++] = dist >> 8;

Comments

@madler please review the suggested style above and accept or propose a preferred style. Cheers.

@madler
Copy link
Owner

madler commented Oct 6, 2022

I do not plan to remove the pre-ISO C compatibility at this time. I would recommend simply turning off that warning.

@madler madler closed this as completed Oct 6, 2022
@rosasco-wk
Copy link
Author

rosasco-wk commented Oct 8, 2022 via email

@madler
Copy link
Owner

madler commented Oct 9, 2022

"not at this time" means not for the next version. I need to get a version out to fix some things, so it's not the time to break stuff. If C2X does in fact deprecate K&R function declarations completely, then I will eventually need to get rid of them. (clang seems to be jumping the gun here — it hasn't even happened yet. I think the C2X finalization is supposed to be at the end of this year.)

As for a style, surely the easiest thing to do would be to just remove the function arguments and close parenthesis and change the semicolons to commas, except the last semicolon becomes the new close parenthesis. Could be done with a script.

Come to think of it, there already is a Perl script to do this in the zlib distribution, called zlib2ansi. I haven't tried it in a long time, so I'm not certain it works.

@rosasco-wk
Copy link
Author

rosasco-wk commented Oct 11, 2022 via email

@madler
Copy link
Owner

madler commented Oct 11, 2022

By style I was referring to how you wanted the existing inline comments per parameter to appear in the updated, ANSI-compliant functions. Are bugs normally closed in zlib that aren't applicable to the next version ? (i.e. the description of not at this time)

That's what I answered. The comments should appear just as they do now. All you need to do is change the semicolons to commas or a close parenthesis.

I don't understand your question.

@rosasco-wk
Copy link
Author

rosasco-wk commented Oct 11, 2022 via email

@madler
Copy link
Owner

madler commented Oct 11, 2022

Ah. I closed this because this is a duplicate of #633 . I didn't realize that I had closed that one as well, so I just reopened it.

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

No branches or pull requests

2 participants