DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Burakov, Anatoly" <anatoly.burakov@intel.com>
To: "dev@dpdk.org" <dev@dpdk.org>
Subject: [dpdk-dev] FW: couple of minor compilation errors in DPDK 1.6	(/lib/librte_eal/linuxapp/eal/eal_ivshmem.c)
Date: Tue, 4 Feb 2014 11:23:46 +0000	[thread overview]
Message-ID: <C6ECDF3AB251BE4894318F4E45123697591F4BCD@IRSMSX101.ger.corp.intel.com> (raw)
In-Reply-To: <CAJn5u1=yv2izSpVJXKR7HyXHbtNOmqMSey6cEkWGQLAaBfEd_A@mail.gmail.com>

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Jyotiswarup 
> Raiturkar
> Sent: Tuesday, February 04, 2014 3:33 AM
> To: dev@dpdk.org
> Cc: Jyotiswarup Raiturkar
> Subject: [dpdk-dev] couple of minor compilation errors in DPDK 1.6
> (/lib/librte_eal/linuxapp/eal/eal_ivshmem.c)
> 
> Hi
> 
> I downloaded DPDK 1.6 from the Intel website and ran into couple of 
> compilation errors with /lib/librte_eal/linuxapp/eal/eal_ivshmem.c. 
> The following changes seem to fix it.  Have other people seen these?
> 
> Thanks
> Jyoti
> 
> 
> @@ -472,7 +472,7 @@
>   rte_snprintf(path, sizeof(path), IVSHMEM_CONFIG_PATH,
>   internal_config.hugefile_prefix);
> 
> - fd = open(path, O_CREAT | O_RDWR);
> + fd = open(path, O_CREAT | O_RDWR, S_IRWXU | S_IRWXG | S_IRWXO );
> 
>   if (fd < 0) {
>   RTE_LOG(ERR, EAL, "Could not open %s: %s\n", path, strerror(errno)); 
> @@ -
> 486,7 +486,8 @@
>   return -1;
>   }
> 
> - ftruncate(fd, sizeof(struct ivshmem_shared_config));
> + if (ftruncate(fd, sizeof(struct ivshmem_shared_config))) {
> +                close(fd); return -1;
> +      }
> 
>   ivshmem_config = mmap(NULL, sizeof(struct ivshmem_shared_config),
>   PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);

Hi

I don't think assigning 0777 to a newly created file is a good idea, I would prefer 0666. Other than that, there is also another place where a call to close() should be added, so the correct patch would be:

@@ -443,7 +443,7 @@ create_shared_config(void)
        rte_snprintf(path, sizeof(path), IVSHMEM_CONFIG_PATH,
                        internal_config.hugefile_prefix);

-       fd = open(path, O_CREAT | O_RDWR);
+       fd = open(path, O_CREAT | O_RDWR, 0666);

        if (fd < 0) {
                RTE_LOG(ERR, EAL, "Could not open %s: %s\n", path, strerror(errno)); @@ -462,14 +462,17 @@ create_shared_config(void)
        ivshmem_config = mmap(NULL, sizeof(struct ivshmem_shared_config),
                        PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);

-       if (ivshmem_config == MAP_FAILED)
+       if (ivshmem_config == MAP_FAILED) {
+               close(fd);
                return -1;
+       }

        memset(ivshmem_config, 0, sizeof(struct ivshmem_shared_config));

        /* change the exclusive lock we got earlier to a shared lock */
        if (flock(fd, LOCK_SH | LOCK_NB) == -1) {
                RTE_LOG(ERR, EAL, "Locking %s failed: %s \n", path, strerror(errno));
+               close(fd);
                return -1;
        }

Best regards,
Anatoly Burakov
DPDK SW Engineer
--------------------------------------------------------------
Intel Shannon Limited
Registered in Ireland
Registered Office: Collinstown Industrial Park, Leixlip, County Kildare
Registered Number: 308263
Business address: Dromore House, East Park, Shannon, Co. Clare

This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.

      reply	other threads:[~2014-02-04 11:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-04  3:32 [dpdk-dev] " Jyotiswarup Raiturkar
2014-02-04 11:23 ` Burakov, Anatoly [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=C6ECDF3AB251BE4894318F4E45123697591F4BCD@IRSMSX101.ger.corp.intel.com \
    --to=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 NNTP newsgroup(s).