Prior to this commit the value stored to s at initialization was never read (in the case of STRERROR_R_CHAR_P).
[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-
practicalswift commented at 9:56 PM on January 12, 2017: contributor
- dcousens approved
- 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 - fanquake added the label Refactoring on Jan 13, 2017
-
practicalswift commented at 6:01 PM on January 13, 2017: contributor
Replaced
[trivial]with[net]in commit title. - practicalswift force-pushed on Jan 13, 2017
-
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.
practicalswift commented at 10:19 PM on February 27, 2017: contributorAny changes needed before merge? :-)
paveljanik commented at 12:37 PM on February 28, 2017: contributorIn such cases, I personally prefer
const char *s;at the beginning before conditional and then simple assignments.5844609451[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).
practicalswift force-pushed on Feb 28, 2017practicalswift commented at 1:25 PM on February 28, 2017: contributor@paveljanik Good point! Changed and pushed. Looks good? :-)
paveljanik commented at 2:35 PM on February 28, 2017: contributorpracticalswift 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 :-)
laanwj commented at 5:39 PM on May 23, 2017: memberutACK 5844609
laanwj merged this on May 23, 2017laanwj closed this on May 23, 2017laanwj referenced this in commit 7e96ecf075 on May 23, 2017PastaPastaPasta referenced this in commit 671887f99a on Jun 10, 2019PastaPastaPasta referenced this in commit f1f4c12d69 on Jun 11, 2019PastaPastaPasta referenced this in commit af9eec0654 on Jun 11, 2019PastaPastaPasta referenced this in commit b9135d26d9 on Jun 15, 2019PastaPastaPasta referenced this in commit c230605897 on Jun 19, 2019PastaPastaPasta referenced this in commit f8c36e2918 on Jun 19, 2019PastaPastaPasta referenced this in commit b6a792af41 on Jun 19, 2019PastaPastaPasta referenced this in commit c2b2efcd32 on Jun 19, 2019PastaPastaPasta referenced this in commit cfc7bc90b1 on Jun 19, 2019PastaPastaPasta referenced this in commit 28bbd306a2 on Jun 20, 2019PastaPastaPasta referenced this in commit 27b5d1af43 on Jun 22, 2019PastaPastaPasta referenced this in commit 997de3fde1 on Jun 22, 2019PastaPastaPasta referenced this in commit f66fe13d94 on Jun 22, 2019PastaPastaPasta referenced this in commit eea9dacc3c on Jun 22, 2019PastaPastaPasta referenced this in commit c92f79bfaa on Jun 22, 2019PastaPastaPasta referenced this in commit 0477eb4b39 on Jun 24, 2019barrystyle referenced this in commit d269a8da8d on Jan 22, 2020random-zebra referenced this in commit d9cbbad1dc on Dec 14, 2020practicalswift deleted the branch on Apr 10, 2021DrahtBot locked this on Aug 16, 2022Labels
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 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
More mirrored repositories can be found on mirror.b10c.me