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

Silence strncpy warnings #12501

Merged
merged 5 commits into from May 7, 2019
Merged

Commits on May 7, 2019

  1. network: remove redunant link name in message

    Fixes systemd#12454.
    
    gcc was complaining that the link->ifname argument is NULL. Adding
    assert(link->ifname) right before the call has no effect. It seems that
    gcc is confused by the fact that log_link_warning_errno() internally
    calls log_object(), with link->ifname passed as the object. log_object()
    is also a macro and is does a check whether the passed object is NULL.
    So we have a check if something is NULL right next an unconditional use
    of it where it cannot be NULL. I think it's a bug in gcc.
    
    Anyway, we don't need to use link->ifname here. log_object() already prepends
    the object name to the message.
    keszybz committed May 7, 2019
    Configuration menu
    Copy the full SHA
    c98b354 View commit details
    Browse the repository at this point in the history
  2. shared/utmp-wtmp: avoid gcc warning about strncpy truncation

    The fact that strncpy does the truncation is the whole point here, and gcc
    shouldn't warn about this. We can avoid the warning and simplify the
    whole procedure by directly copying the interesting part.
    keszybz committed May 7, 2019
    Configuration menu
    Copy the full SHA
    f1d553e View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    881a62d View commit details
    Browse the repository at this point in the history
  4. shared/utmp-wtmp: silence gcc warning about strncpy truncation

    Unfortunately the warning must be known, or otherwise the pragma generates a
    warning or an error. So let's do a meson check for it.
    
    Is it worth doing this to silence the warning? I think so, because apparently
    the warning was already emitted by gcc-8.1, and with the recent push in gcc to
    catch more such cases, we'll most likely only get more of those.
    keszybz committed May 7, 2019
    Configuration menu
    Copy the full SHA
    6695c20 View commit details
    Browse the repository at this point in the history
  5. scsi_serial: replace some crazy strncpy() calls by strnlen()

    gcc was warning about strncpy() leaving an unterminated string.
    In this case, it was correct.
    
    The code was doing strncpy()+strncat()+strlen() essentially to determine
    if the strings have expected length. If the length was correct, a buffer
    overread was performed (or at least some garbage bytes were used from the
    uninitialized part of the buffer). Let's do the length check first and then
    only copy stuff if everything agrees.
    
    For some reason the function was called "prepend", when it obviously does
    an "append".
    keszybz committed May 7, 2019
    Configuration menu
    Copy the full SHA
    099c77f View commit details
    Browse the repository at this point in the history