[net] Avoid initialization to a value that is never read #9539

pull practicalswift wants to merge 1 commits into bitcoin:master from practicalswift:avoid-initialization-to-a-value-that-is-never-read changing 1 files +2 −1
  1. practicalswift commented at 9:56 PM on January 12, 2017: contributor

    Prior to this commit the value stored to s at initialization was never read (in the case of STRERROR_R_CHAR_P).

  2. dcousens approved
  3. fanquake renamed this:
    [trivial] Avoid initialization to a value that is never read
    [net] Avoid initialization to a value that is never read
    on Jan 13, 2017
  4. fanquake added the label Refactoring on Jan 13, 2017
  5. practicalswift commented at 6:01 PM on January 13, 2017: contributor

    Replaced [trivial] with [net] in commit title.

  6. practicalswift force-pushed on Jan 13, 2017
  7. in src/netbase.cpp:None in 0ec6d148fd outdated
     665 | +    const char *s = strerror_r(err, buf, sizeof(buf));
     666 |  #else /* POSIX variant always returns message in buffer */
     667 | +    const char *s = buf;
     668 |      if (strerror_r(err, buf, sizeof(buf)))
     669 |          buf[0] = 0;
     670 |  #endif
    


    TheBlueMatt commented at 4:18 PM on February 7, 2017:

    It looks like, in the case of non-STRERROR_R_CHAR_P, you'll get an error on the line below.


    practicalswift commented at 5:20 PM on February 7, 2017:

    @TheBlueMatt I'm not sure I follow. The intention is to keep the logic unchanged minus the redundant initialization. What am I missing? :-)


    TheBlueMatt commented at 5:29 PM on February 7, 2017:

    Ahh, somehow I missed the second line-addition, sorry.

  8. practicalswift commented at 10:19 PM on February 27, 2017: contributor

    Any changes needed before merge? :-)

  9. paveljanik commented at 12:37 PM on February 28, 2017: contributor

    In such cases, I personally prefer const char *s; at the beginning before conditional and then simple assignments.

  10. [net] Avoid initialization to a value that is never read
    Prior to this commit the value stored to `s` at initialization
    was never read (in the case of STRERROR_R_CHAR_P).
    5844609451
  11. practicalswift force-pushed on Feb 28, 2017
  12. practicalswift commented at 1:25 PM on February 28, 2017: contributor

    @paveljanik Good point! Changed and pushed. Looks good? :-)

  13. practicalswift commented at 8:26 PM on April 10, 2017: contributor

    @laanwj Do you have any input with regards to this change? If I'm reading the history correctly I think you've touched this specific function :-)

  14. laanwj commented at 5:39 PM on May 23, 2017: member

    utACK 5844609

  15. laanwj merged this on May 23, 2017
  16. laanwj closed this on May 23, 2017

  17. laanwj referenced this in commit 7e96ecf075 on May 23, 2017
  18. PastaPastaPasta referenced this in commit 671887f99a on Jun 10, 2019
  19. PastaPastaPasta referenced this in commit f1f4c12d69 on Jun 11, 2019
  20. PastaPastaPasta referenced this in commit af9eec0654 on Jun 11, 2019
  21. PastaPastaPasta referenced this in commit b9135d26d9 on Jun 15, 2019
  22. PastaPastaPasta referenced this in commit c230605897 on Jun 19, 2019
  23. PastaPastaPasta referenced this in commit f8c36e2918 on Jun 19, 2019
  24. PastaPastaPasta referenced this in commit b6a792af41 on Jun 19, 2019
  25. PastaPastaPasta referenced this in commit c2b2efcd32 on Jun 19, 2019
  26. PastaPastaPasta referenced this in commit cfc7bc90b1 on Jun 19, 2019
  27. PastaPastaPasta referenced this in commit 28bbd306a2 on Jun 20, 2019
  28. PastaPastaPasta referenced this in commit 27b5d1af43 on Jun 22, 2019
  29. PastaPastaPasta referenced this in commit 997de3fde1 on Jun 22, 2019
  30. PastaPastaPasta referenced this in commit f66fe13d94 on Jun 22, 2019
  31. PastaPastaPasta referenced this in commit eea9dacc3c on Jun 22, 2019
  32. PastaPastaPasta referenced this in commit c92f79bfaa on Jun 22, 2019
  33. PastaPastaPasta referenced this in commit 0477eb4b39 on Jun 24, 2019
  34. barrystyle referenced this in commit d269a8da8d on Jan 22, 2020
  35. random-zebra referenced this in commit d9cbbad1dc on Dec 14, 2020
  36. practicalswift deleted the branch on Apr 10, 2021
  37. DrahtBot locked this on Aug 16, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-16 15:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me