Re: Report man-pages-6.01 bug

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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: OpenPGP_signature
Description: OpenPGP digital signature


[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux