diff mbox

[PATCHv8,1/6] linux-generic: set not initialized socket to -1

Message ID 1418147090-29055-2-git-send-email-maxim.uvarov@linaro.org
State New
Headers show

Commit Message

Maxim Uvarov Dec. 9, 2014, 5:44 p.m. UTC
In case of stdin is not attached socket() can return 0 for valid
socket fd. Not initialized socket has to be -1.

Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
Reviewed-by: Stuart Haslam <stuart.haslam@arm.com>
---
 platform/linux-generic/odp_packet_io.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

vkamensky Dec. 9, 2014, 6 p.m. UTC | #1
On 9 December 2014 at 09:44, Maxim Uvarov <maxim.uvarov@linaro.org> wrote:
> In case of stdin is not attached socket() can return 0 for valid
> socket fd. Not initialized socket has to be -1.
>
> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
> Reviewed-by: Stuart Haslam <stuart.haslam@arm.com>

Reviewed-by: Victor Kamensky <victor.kamensky@linaro.org>

> ---
>  platform/linux-generic/odp_packet_io.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c
> index 706a3cc..faa197f 100644
> --- a/platform/linux-generic/odp_packet_io.c
> +++ b/platform/linux-generic/odp_packet_io.c
> @@ -114,6 +114,9 @@ static void init_pktio_entry(pktio_entry_t *entry)
>         entry->s.inq_default = ODP_QUEUE_INVALID;
>         memset(&entry->s.pkt_sock, 0, sizeof(entry->s.pkt_sock));
>         memset(&entry->s.pkt_sock_mmap, 0, sizeof(entry->s.pkt_sock_mmap));
> +       /* set sockfd to -1, because a valid socked might be initialized to 0 */
> +       entry->s.pkt_sock.sockfd = -1;
> +       entry->s.pkt_sock_mmap.sockfd = -1;
>  }
>
>  static odp_pktio_t alloc_lock_pktio_entry(void)
> --
> 1.8.5.1.163.gd7aced9
>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
diff mbox

Patch

diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c
index 706a3cc..faa197f 100644
--- a/platform/linux-generic/odp_packet_io.c
+++ b/platform/linux-generic/odp_packet_io.c
@@ -114,6 +114,9 @@  static void init_pktio_entry(pktio_entry_t *entry)
 	entry->s.inq_default = ODP_QUEUE_INVALID;
 	memset(&entry->s.pkt_sock, 0, sizeof(entry->s.pkt_sock));
 	memset(&entry->s.pkt_sock_mmap, 0, sizeof(entry->s.pkt_sock_mmap));
+	/* set sockfd to -1, because a valid socked might be initialized to 0 */
+	entry->s.pkt_sock.sockfd = -1;
+	entry->s.pkt_sock_mmap.sockfd = -1;
 }
 
 static odp_pktio_t alloc_lock_pktio_entry(void)