Hi! On 11/3/22 19:33, 1092615079 wrote:
Dear Devloper,Thanks for your reply, and i am very sorry because i am not good at making patch, so i try to show the point for you.The part of code which i think may be incorrect in EXAMPLE is like follow: --begin-- struct shmbuf *shmp; *shmp = mmap(NULL, sizeof(*shmp), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); --end--I think the problem is that the pointer variable <shmp> is directly used to access memory without init, and i think the original intention of the code is like this:--begin-- struct shmbuf *shmp; shmp = mmap(NULL, sizeof(*shmp), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); --end-- I think shmp maybe just be used to get the return value of mmap(); PS: The page file is shm_open.3 and hope this can do something useful for you. Thanks for your contribution again!
Thank you for the report and the explanation. I fixed the bug. It seems it was probably a typo.
<https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/commit/> Cheers, Alex
------------------ 原始邮件 ------------------ *发件人:* "Alejandro Colomar" <alx.manpages@xxxxxxxxx>; *发送时间:* 2022年11月3日(星期四) 晚上11:13 *收件人:* " "<1092615079@xxxxxx>; *抄送:* "linux-man"<linux-man@xxxxxxxxxxxxxxx>; *主题:* Re: Report man-pages-6.01 bug Hello, On 11/3/22 09:01, 1092615079 wrote: > Dear Devloper, > In the EXAMPLES of shm_open in man-pages-6.01 section 3, i think the usage > of variable shmp in the code of pshm_ucase_bounce.c maybe has a clerical error > with a redundant action about address accessing , please see: I don't have much experience using mmap(2). Could you please detail why you think this is incorrect, and hopefully propose a patch? You may want to read this for preparing a patch: <https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/tree/CONTRIBUTING> Thanks, Alex > > /* pshm_ucase_bounce.c > > Licensed under GNU General Public License v2 or later. > */ > #include <ctype.h> > > #include "pshm_ucase.h" > > int > main(int argc, char *argv[]) > { > int fd; > char *shmpath; > struct shmbuf *shmp; > > if (argc != 2) { > fprintf(stderr, "Usage: %s /shm\-path\en", argv[0]); > exit(EXIT_FAILURE); > } > > shmpath = argv[1]; > > /* Create shared memory object and set its size to the size > of our structure. */ > > fd = shm_open(shmpath, O_CREAT | O_EXCL | O_RDWR, 0600); > if (fd == \-1) > errExit("shm_open"); > > if (ftruncate(fd, sizeof(struct shmbuf)) == \-1) > errExit("ftruncate"); > > /* Map the object into the caller\(aqs address space. */ > > *shmp = mmap(NULL, sizeof(*shmp), PROT_READ | PROT_WRITE, > MAP_SHARED, fd, 0); > if (shmp == MAP_FAILED) > errExit("mmap"); > > > thanks for your contribution again. -- <http://www.alejandro-colomar.es/>
-- <http://www.alejandro-colomar.es/>
Attachment:
OpenPGP_signature
Description: OpenPGP digital signature