Message ID | 1417450537-7640-11-git-send-email-maxim.uvarov@linaro.org |
---|---|
State | New |
Headers | show |
On 12/02/2014 03:56 PM, Savolainen, Petri (NSN - FI/Espoo) wrote: > These error codes should be passed through errno variable. The return value should just indicate success vs. failure. See error code update on the v1.0 delta doc. > > -Petri > Petri, yesterday I rose question about switching to return codes in way as your patch does. Everybody liked this solution. We also do not use errno anywhere in code. Unfortunately you were absent and I could not check it with you yesterday. From one thing we should be consistent with all other APIs from other returns codes in that way is very natural (like read(), write(), ioctl() do). From my point of view we do not break code style / rules here. So please confirm. Thanks, Maxim. >> -----Original Message----- >> From: lng-odp-bounces@lists.linaro.org [mailto:lng-odp- >> bounces@lists.linaro.org] On Behalf Of ext Maxim Uvarov >> Sent: Monday, December 01, 2014 6:16 PM >> To: lng-odp@lists.linaro.org >> Subject: [lng-odp] [PATCHv4 10/11] API and linux-generic: pktio update >> return codes >> >> Update return codes to readable values. >> >> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org> >> --- >> platform/linux-generic/include/api/odp_packet_io.h | 16 +++++++--------- >> platform/linux-generic/odp_packet_io.c | 20 ++++++++++------- >> --- >> 2 files changed, 17 insertions(+), 19 deletions(-) >> >> diff --git a/platform/linux-generic/include/api/odp_packet_io.h >> b/platform/linux-generic/include/api/odp_packet_io.h >> index 1190355..0b9e34b 100644 >> --- a/platform/linux-generic/include/api/odp_packet_io.h >> +++ b/platform/linux-generic/include/api/odp_packet_io.h >> @@ -137,8 +137,7 @@ odp_pktio_t odp_pktio_get_input(odp_packet_t pkt); >> * use. >> * >> * @retval 0 on success. >> - * @retval -1 if specified mtu can not be handled. >> - * @retval -1 on any other error or illegal input parameters. >> + * @retval -ERROR on error. >> */ >> int odp_pktio_set_mtu(odp_pktio_t id, int mtu); >> >> @@ -148,7 +147,7 @@ int odp_pktio_set_mtu(odp_pktio_t id, int mtu); >> * @param[in] id ODP packet IO handle. >> * >> * @retval MTU value >0 on success. >> - * @retval -1 on any error or not existance pktio id. >> + * @retval -ERROR on error. >> */ >> int odp_pktio_mtu(odp_pktio_t id); >> >> @@ -159,8 +158,7 @@ int odp_pktio_mtu(odp_pktio_t id); >> * @param[in] enable 1 enabled, 0 disabled. >> * >> * @retval 0 on success. >> - * @retval -1 on a bad pktio id >> - * @retval -1 any other error >> + * @retval -ERROR on error. >> */ >> int odp_pktio_promisc_set(odp_pktio_t id, odp_bool_t enable); >> >> @@ -171,8 +169,7 @@ int odp_pktio_promisc_set(odp_pktio_t id, odp_bool_t >> enable); >> * >> * @retval 1 if promiscuous mode is enabled. >> * @retval 0 if promiscuous mode is disabled. >> - * @retval -1 on a bad pktio id >> - * @retval -1 any other error >> + * @retval -ERROR on error. >> */ >> int odp_pktio_promisc_enabled(odp_pktio_t id); >> >> @@ -183,8 +180,9 @@ int odp_pktio_promisc_enabled(odp_pktio_t id); >> * @param[in] mac_addr MAC address to be assigned to the interface. >> * @param[in] addr_size Size of the address in bytes. >> * >> - * @return 0 on success, -ERROR on error. >> - */ >> + * @retval return 0 on success >> + * @retval -ERROR on error. >> +*/ >> int odp_pktio_mac_addr_set(odp_pktio_t id, const unsigned char *mac_addr, >> size_t addr_size); >> >> diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux- >> generic/odp_packet_io.c >> index 6c8307e..7d985fb 100644 >> --- a/platform/linux-generic/odp_packet_io.c >> +++ b/platform/linux-generic/odp_packet_io.c >> @@ -552,13 +552,13 @@ int odp_pktio_set_mtu(odp_pktio_t id, int mtu) >> >> if (mtu <= 0) { >> ODP_DBG("illegal MTU value %d\n", mtu); >> - return -1; >> + return -EINVAL; >> } >> >> entry = get_entry(id); >> if (entry == NULL) { >> ODP_DBG("pktio entry %d does not exist\n", id); >> - return -1; >> + return -ENOENT; >> } >> >> if (entry->s.pkt_sock_mmap.sockfd > -1) >> @@ -573,7 +573,7 @@ int odp_pktio_set_mtu(odp_pktio_t id, int mtu) >> ret = ioctl(sockfd, SIOCSIFMTU, (caddr_t)&ifr); >> if (ret < 0) { >> ODP_DBG("ioctl SIOCSIFMTU error\n"); >> - return -1; >> + return ret; >> } >> >> return 0; >> @@ -589,7 +589,7 @@ int odp_pktio_mtu(odp_pktio_t id) >> entry = get_entry(id); >> if (entry == NULL) { >> ODP_DBG("pktio entry %d does not exist\n", id); >> - return -1; >> + return -ENOENT; >> } >> >> if (entry->s.pkt_sock_mmap.sockfd > -1) >> @@ -603,7 +603,7 @@ int odp_pktio_mtu(odp_pktio_t id) >> ret = ioctl(sockfd, SIOCGIFMTU, &ifr); >> if (ret < 0) { >> ODP_DBG("ioctl SIOCGIFMTU error\n"); >> - return -1; >> + return ret; >> } >> >> return ifr.ifr_mtu; >> @@ -619,7 +619,7 @@ int odp_pktio_promisc_set(odp_pktio_t id, odp_bool_t >> enable) >> entry = get_entry(id); >> if (entry == NULL) { >> ODP_DBG("pktio entry %d does not exist\n", id); >> - return -1; >> + return -ENOENT; >> } >> >> if (entry->s.pkt_sock_mmap.sockfd > -1) >> @@ -633,7 +633,7 @@ int odp_pktio_promisc_set(odp_pktio_t id, odp_bool_t >> enable) >> ret = ioctl(sockfd, SIOCGIFFLAGS, &ifr); >> if (ret < 0) { >> ODP_DBG("ioctl SIOCGIFFLAGS error\n"); >> - return -1; >> + return ret; >> } >> >> if (enable) >> @@ -644,7 +644,7 @@ int odp_pktio_promisc_set(odp_pktio_t id, odp_bool_t >> enable) >> ret = ioctl(sockfd, SIOCSIFFLAGS, &ifr); >> if (ret < 0) { >> ODP_DBG("ioctl SIOCSIFFLAGS error\n"); >> - return -1; >> + return ret; >> } >> >> return 0; >> @@ -660,7 +660,7 @@ int odp_pktio_promisc_enabled(odp_pktio_t id) >> entry = get_entry(id); >> if (entry == NULL) { >> ODP_DBG("pktio entry %d does not exist\n", id); >> - return -1; >> + return -ENOENT; >> } >> >> if (entry->s.pkt_sock_mmap.sockfd > -1) >> @@ -674,7 +674,7 @@ int odp_pktio_promisc_enabled(odp_pktio_t id) >> ret = ioctl(sockfd, SIOCGIFFLAGS, &ifr); >> if (ret < 0) { >> ODP_DBG("ioctl SIOCGIFFLAGS error\n"); >> - return -1; >> + return ret; >> } >> >> if (ifr.ifr_flags & IFF_PROMISC) >> -- >> 1.8.5.1.163.gd7aced9 >> >> >> _______________________________________________ >> lng-odp mailing list >> lng-odp@lists.linaro.org >> http://lists.linaro.org/mailman/listinfo/lng-odp
diff --git a/platform/linux-generic/include/api/odp_packet_io.h b/platform/linux-generic/include/api/odp_packet_io.h index 1190355..0b9e34b 100644 --- a/platform/linux-generic/include/api/odp_packet_io.h +++ b/platform/linux-generic/include/api/odp_packet_io.h @@ -137,8 +137,7 @@ odp_pktio_t odp_pktio_get_input(odp_packet_t pkt); * use. * * @retval 0 on success. - * @retval -1 if specified mtu can not be handled. - * @retval -1 on any other error or illegal input parameters. + * @retval -ERROR on error. */ int odp_pktio_set_mtu(odp_pktio_t id, int mtu); @@ -148,7 +147,7 @@ int odp_pktio_set_mtu(odp_pktio_t id, int mtu); * @param[in] id ODP packet IO handle. * * @retval MTU value >0 on success. - * @retval -1 on any error or not existance pktio id. + * @retval -ERROR on error. */ int odp_pktio_mtu(odp_pktio_t id); @@ -159,8 +158,7 @@ int odp_pktio_mtu(odp_pktio_t id); * @param[in] enable 1 enabled, 0 disabled. * * @retval 0 on success. - * @retval -1 on a bad pktio id - * @retval -1 any other error + * @retval -ERROR on error. */ int odp_pktio_promisc_set(odp_pktio_t id, odp_bool_t enable); @@ -171,8 +169,7 @@ int odp_pktio_promisc_set(odp_pktio_t id, odp_bool_t enable); * * @retval 1 if promiscuous mode is enabled. * @retval 0 if promiscuous mode is disabled. - * @retval -1 on a bad pktio id - * @retval -1 any other error + * @retval -ERROR on error. */ int odp_pktio_promisc_enabled(odp_pktio_t id); @@ -183,8 +180,9 @@ int odp_pktio_promisc_enabled(odp_pktio_t id); * @param[in] mac_addr MAC address to be assigned to the interface. * @param[in] addr_size Size of the address in bytes. * - * @return 0 on success, -ERROR on error. - */ + * @retval return 0 on success + * @retval -ERROR on error. +*/ int odp_pktio_mac_addr_set(odp_pktio_t id, const unsigned char *mac_addr, size_t addr_size); diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index 6c8307e..7d985fb 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -552,13 +552,13 @@ int odp_pktio_set_mtu(odp_pktio_t id, int mtu) if (mtu <= 0) { ODP_DBG("illegal MTU value %d\n", mtu); - return -1; + return -EINVAL; } entry = get_entry(id); if (entry == NULL) { ODP_DBG("pktio entry %d does not exist\n", id); - return -1; + return -ENOENT; } if (entry->s.pkt_sock_mmap.sockfd > -1) @@ -573,7 +573,7 @@ int odp_pktio_set_mtu(odp_pktio_t id, int mtu) ret = ioctl(sockfd, SIOCSIFMTU, (caddr_t)&ifr); if (ret < 0) { ODP_DBG("ioctl SIOCSIFMTU error\n"); - return -1; + return ret; } return 0; @@ -589,7 +589,7 @@ int odp_pktio_mtu(odp_pktio_t id) entry = get_entry(id); if (entry == NULL) { ODP_DBG("pktio entry %d does not exist\n", id); - return -1; + return -ENOENT; } if (entry->s.pkt_sock_mmap.sockfd > -1) @@ -603,7 +603,7 @@ int odp_pktio_mtu(odp_pktio_t id) ret = ioctl(sockfd, SIOCGIFMTU, &ifr); if (ret < 0) { ODP_DBG("ioctl SIOCGIFMTU error\n"); - return -1; + return ret; } return ifr.ifr_mtu; @@ -619,7 +619,7 @@ int odp_pktio_promisc_set(odp_pktio_t id, odp_bool_t enable) entry = get_entry(id); if (entry == NULL) { ODP_DBG("pktio entry %d does not exist\n", id); - return -1; + return -ENOENT; } if (entry->s.pkt_sock_mmap.sockfd > -1) @@ -633,7 +633,7 @@ int odp_pktio_promisc_set(odp_pktio_t id, odp_bool_t enable) ret = ioctl(sockfd, SIOCGIFFLAGS, &ifr); if (ret < 0) { ODP_DBG("ioctl SIOCGIFFLAGS error\n"); - return -1; + return ret; } if (enable) @@ -644,7 +644,7 @@ int odp_pktio_promisc_set(odp_pktio_t id, odp_bool_t enable) ret = ioctl(sockfd, SIOCSIFFLAGS, &ifr); if (ret < 0) { ODP_DBG("ioctl SIOCSIFFLAGS error\n"); - return -1; + return ret; } return 0; @@ -660,7 +660,7 @@ int odp_pktio_promisc_enabled(odp_pktio_t id) entry = get_entry(id); if (entry == NULL) { ODP_DBG("pktio entry %d does not exist\n", id); - return -1; + return -ENOENT; } if (entry->s.pkt_sock_mmap.sockfd > -1) @@ -674,7 +674,7 @@ int odp_pktio_promisc_enabled(odp_pktio_t id) ret = ioctl(sockfd, SIOCGIFFLAGS, &ifr); if (ret < 0) { ODP_DBG("ioctl SIOCGIFFLAGS error\n"); - return -1; + return ret; } if (ifr.ifr_flags & IFF_PROMISC)
Update return codes to readable values. Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org> --- platform/linux-generic/include/api/odp_packet_io.h | 16 +++++++--------- platform/linux-generic/odp_packet_io.c | 20 ++++++++++---------- 2 files changed, 17 insertions(+), 19 deletions(-)