Linux-man Archive mirror
 help / color / mirror / Atom feed
* Re: Report man-pages-6.01 bug
       [not found] <tencent_A7B85DF7875B85CB9A7DDFB793F193852F07@qq.com>
@ 2022-11-03 15:13 ` Alejandro Colomar
       [not found]   ` <tencent_F782FBCDADC9E5CD7ED5DBC738CD4223DC06@qq.com>
  0 siblings, 1 reply; 2+ messages in thread
From: Alejandro Colomar @ 2022-11-03 15:13 UTC (permalink / raw
  To: 1092615079; +Cc: linux-man


[-- Attachment #1.1: Type: text/plain, Size: 1776 bytes --]

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/>

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Reply: Report man-pages-6.01 bug
       [not found]   ` <tencent_F782FBCDADC9E5CD7ED5DBC738CD4223DC06@qq.com>
@ 2022-12-11 17:26     ` Alejandro Colomar
  0 siblings, 0 replies; 2+ messages in thread
From: Alejandro Colomar @ 2022-12-11 17:26 UTC (permalink / raw
  To: 1092615079; +Cc: linux-man


[-- Attachment #1.1: Type: text/plain, Size: 3526 bytes --]

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@gmail.com>;
> *发送时间:* 2022年11月3日(星期四) 晚上11:13
> *收件人:* " "<1092615079@qq.com>;
> *抄送:* "linux-man"<linux-man@vger.kernel.org>;
> *主题:* 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 #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-12-11 17:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <tencent_A7B85DF7875B85CB9A7DDFB793F193852F07@qq.com>
2022-11-03 15:13 ` Report man-pages-6.01 bug Alejandro Colomar
     [not found]   ` <tencent_F782FBCDADC9E5CD7ED5DBC738CD4223DC06@qq.com>
2022-12-11 17:26     ` Reply: " Alejandro Colomar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).