mirror of https://github.com/mkerrisk/man-pages
44a16bcb61
From an email conversation with Alexis: Hello Alexis, On 8/6/21 7:06 PM, Alexis Wilke wrote: > Hi guys, > > The pthread_setname_np(3) manual page has an example where the second > argument is used to get a size of the thread name. > > https://man7.org/linux/man-pages/man3/pthread_setname_np.3.html#EXAMPLES > > The current code: > > rc = pthread_getname_np(thread, thread_name, > (argc > 2) ? atoi(argv[1]) : NAMELEN); > > The suggested code: > > rc = pthread_getname_np(thread, thread_name, > (argc > 2) ? atoi(argv[2]) : NAMELEN); I agree that there's a problem, but I think we could go even simpler: rc = pthread_getname_np(thread, thread_name, NAMELEN); > I'm thinking that maybe the author meant to compute the length like so: > > rc = pthread_getname_np(thread, thread_name, > (argc > 2) ? strlen(argv[1]) + 1 : > NAMELEN); > > But I think that the atoi() points to using argv[2] as a number > representing the length. > > (Of course, it should be tested against NAMELEN as a maximum, but I > understand that examples do not always show how to verify each possible > error). I imagine that the author's intention was to allow the user to do experiments where argv[2] specified a number less than NAMELEN, in order to see the resulting ERANGE error. But, that experiment is of limited value, and complicates the code unnecessarily, IMO, so that's why I made the change above. -- Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/ Reported-by: Alexis Wilke <alexis@m2osw.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com> |
||
---|---|---|
man1 | ||
man2 | ||
man3 | ||
man4 | ||
man5 | ||
man6 | ||
man7 | ||
man8 | ||
scripts | ||
.gitignore | ||
CONTRIBUTING | ||
Changes | ||
Changes.old | ||
MAINTAINER_NOTES | ||
Makefile | ||
README | ||
man-pages-5.13.Announce | ||
man-pages-5.13.lsm |
README
This package contains Linux man pages for sections 1 through 8. Some more information is given in the 'man-pages-x.y.Announce' file. Homepage ======== For information about the Linux man-pages project, see http://www.kernel.org/doc/man-pages/index.html. Bug reports and contributing ============================ If you have corrections and additions to suggest, see http://www.kernel.org/doc/man-pages/contributing.html (Although there is a mirror of this repository on GitHub, please don't report issues via the GitHub issue tracker!) For further information on contributing, see the CONTRIBUTING file. Installing and uninstalling =========================== "make install" will copy these man pages to /usr/local/share/man/man[1-8]. To install to a path different from /usr/local, use "make install prefix=/install/path". "make remove" or "make uninstall" will remove any man page in this distribution from its destination. Use with caution, and remember to use "prefix" if desired, as with the "install" target. To install only a specific man section (mandir) such as man3, use "make install-man3". Similar syntax can be used to uninstall a specific man section, such as man7: "make uninstall-man7". "make" or "make all" will perform "make uninstall" followed by "make install". Consider using multiple threads (at least 2) when installing these man pages, as the Makefile is optimized for multiple threads: "make -j install". Copyrights ========== See the 'man-pages-x.y.Announce' file.