Skip to content

Misc #63

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

Closed
wants to merge 7 commits into from
Closed

Misc #63

wants to merge 7 commits into from

Conversation

cgzones
Copy link
Contributor

@cgzones cgzones commented Apr 18, 2021

  • Enable several compiler warnings
    Enable common compiler warnings supported by GCC and Clang.

  • Add format attributes
    Enable compilers to check for format string issues.

    endlessh.c: In function ‘logstdio’:
    endlessh.c:80:9: warning: function ‘logstdio’ might be a candidate for ‘gnu_printf’ format attribute [-Wsuggest-attribute=format]
       80 |         vprintf(format, ap);
          |         ^~~~~~~
    endlessh.c: In function ‘logsyslog’:
    endlessh.c1009: warning: function ‘logsyslog’ might be a candidate for ‘gnu_printf’ format attribute [-Wsuggest-attribute=format]
      100 |         vsnprintf(buf, sizeof buf, format, ap);
          |         ^~~~~~~~~
    
    endlessh.c: In function ‘config_log’:
    endlessh.c:509:31: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 3 has type ‘int’ [-Wformat=]
      509 |     logmsg(log_info, "Delay %ld", c->delay);
          |                             ~~^   ~~~~~~~~
          |                               |    |
          |                               |    int
          |                               long int
          |                             %d
    
  • Drop unnecessary parameter name in function typedef

  • Mark file local statistics struct static

  • Mark die() as noreturn
    die() calls exit() and thus never returns.

    endlessh.c:248:1: warning: function 'die' could be declared with attribute 'noreturn' [-Wmissing-noreturn]
    {
    ^
    
  • Mark client parameter of statistics_log_totals const
    statistics_log_totals() does not modify any state.

  • Use unsigned data types
    Use unsigned data types for counters containing only non-negative values to ensure, i.e. on a long-running endlessh instance, potential wrap-arounds are well-defined.

cgzones added 7 commits April 18, 2021 14:51
Enable common compiler warnings supported by GCC and Clang.
Enable compilers to check for format string issues.

endlessh.c: In function ‘logstdio’:
endlessh.c:80:9: warning: function ‘logstdio’ might be a candidate for ‘gnu_printf’ format attribute [-Wsuggest-attribute=format]
   80 |         vprintf(format, ap);
      |         ^~~~~~~
endlessh.c: In function ‘logsyslog’:
endlessh.c:100:9: warning: function ‘logsyslog’ might be a candidate for ‘gnu_printf’ format attribute [-Wsuggest-attribute=format]
  100 |         vsnprintf(buf, sizeof buf, format, ap);
      |         ^~~~~~~~~

endlessh.c: In function ‘config_log’:
endlessh.c:509:31: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 3 has type ‘int’ [-Wformat=]
  509 |     logmsg(log_info, "Delay %ld", c->delay);
      |                             ~~^   ~~~~~~~~
      |                               |    |
      |                               |    int
      |                               long int
      |                             %d
die() calls exit() and thus never returns.

endlessh.c:248:1: warning: function 'die' could be declared with attribute 'noreturn' [-Wmissing-noreturn]
{
^
statistics_log_totals() does not modify any state.
Use unsigned data types for counters containing only non-negative values
to ensure, i.e. on a long-running endlessh instance, potential
wrap-arounds are well-defined.
@cgzones cgzones mentioned this pull request Apr 18, 2021
skeeto pushed a commit that referenced this pull request Apr 30, 2021
skeeto pushed a commit that referenced this pull request Apr 30, 2021
@skeeto
Copy link
Owner

skeeto commented Apr 30, 2021 via email

@cgzones cgzones closed this May 25, 2021
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