Skip to contentSkip to conversation

doc: Fix eth_env_[gs]et_enetaddr() return value

PATCH Superseded Marek Vasut 2 participants 3 messages Dec 18, 2022

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 doc: Fix eth_env_[gs]et_enetaddr() return value

Per env/common.c, eth_env_get_enetaddr() returns the same return values as is_valid_ethaddr(), i.e. true if valid, false otherwise. Per env/common.c, eth_env_set_enetaddr() may return -EEXIST is the ethaddr is already set. Fix both.

---
Cc: Heinrich Schuchardt <[email protected]>
Cc: Marek Behún <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: Tom Rini <[email protected]>

---
 include/env.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/env.h +2 -2
index 60acb5454ec..969737cb75e 100644
@@ -226,7 +226,7 @@ int env_complete(char *var, int maxv, char *cmdv[], int maxsz, char *buf,
  *
  * @name: Environment variable to get (e.g. "ethaddr")
  * @enetaddr: Place to put MAC address (6 bytes)
- * Return: 0 if OK, 1 on error
+ * Return: 1 if OK, 0 on error
  */
 int eth_env_get_enetaddr(const char *name, uint8_t *enetaddr);
 
@@ -235,7 +235,7 @@ int eth_env_get_enetaddr(const char *name, uint8_t *enetaddr);
  *
  * @name: Environment variable to set (e.g. "ethaddr")
  * @enetaddr: Pointer to MAC address to put into the variable (6 bytes)
- * Return: 0 if OK, 1 on error
+ * Return: 0 if OK, -ve on error
  */
 int eth_env_set_enetaddr(const char *name, const uint8_t *enetaddr);
 
Signature · 1 line
2.35.1
#1 lore raw
Quoted 29 lines · Marek Vasut

Per env/common.c, eth_env_get_enetaddr() returns the same return values as is_valid_ethaddr(), i.e. true if valid, false otherwise. Per env/common.c, eth_env_set_enetaddr() may return -EEXIST is the ethaddr is already set. Fix both.

---
Cc: Heinrich Schuchardt <[email protected]>
Cc: Marek Behún <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: Tom Rini <[email protected]>

---
  include/env.h | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
include/env.h +1 -1
index 60acb5454ec..969737cb75e 100644
@@ -226,7 +226,7 @@ int env_complete(char *var, int maxv, char *cmdv[], int maxsz, char *buf,
   *
   * @name: Environment variable to get (e.g. "ethaddr")
   * @enetaddr: Place to put MAC address (6 bytes)
- * Return: 0 if OK, 1 on error
+ * Return: 1 if OK, 0 on error
   */
  int eth_env_get_enetaddr(const char *name, uint8_t *enetaddr);
 

include/env.h int eth_env_get_enetaddr(const char *name, uint8_t *enetaddr); · line 238

Quoted 5 lines
include/env.h +1 -1
@@ -235,7 +235,7 @@ int eth_env_get_enetaddr(const char *name, uint8_t *enetaddr);
   *
   * @name: Environment variable to set (e.g. "ethaddr")
   * @enetaddr: Pointer to MAC address to put into the variable (6 bytes)
- * Return: 0 if OK, 1 on error
+ * Return: 0 if OK, -ve on error

env_set() will return 1 in case of an error. So how about:

Return: 0 if OK, non-zero otherwise

Best regards

Heinrich

Quoted 3 lines
include/env.h +0 -0
   */
  int eth_env_set_enetaddr(const char *name, const uint8_t *enetaddr);
 
#2 lore raw
Quoted 41 lines · Heinrich Schuchardt
Quoted 29 lines · Marek Vasut

Per env/common.c, eth_env_get_enetaddr() returns the same return values as is_valid_ethaddr(), i.e. true if valid, false otherwise. Per env/common.c, eth_env_set_enetaddr() may return -EEXIST is the ethaddr is already set. Fix both.

---
Cc: Heinrich Schuchardt <[email protected]>
Cc: Marek Behún <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: Tom Rini <[email protected]>
---
  include/env.h | 4 ++--

  1 file changed, 2 insertions(+), 2 deletions(-)
include/env.h +1 -1
index 60acb5454ec..969737cb75e 100644
@@ -226,7 +226,7 @@ int env_complete(char *var, int maxv, char 
 *cmdv[], int maxsz, char *buf,
    *
    * @name: Environment variable to get (e.g. "ethaddr")
    * @enetaddr: Place to put MAC address (6 bytes)
- * Return: 0 if OK, 1 on error
+ * Return: 1 if OK, 0 on error
    */
   int eth_env_get_enetaddr(const char *name, uint8_t *enetaddr);

include/env.h int eth_env_get_enetaddr(const char *name, uint8_t · line 239

Quoted 6 lines
include/env.h +1 -1
@@ -235,7 +235,7 @@ int eth_env_get_enetaddr(const char *name, uint8_t 
 *enetaddr);
    *
    * @name: Environment variable to set (e.g. "ethaddr")
    * @enetaddr: Pointer to MAC address to put into the variable (6 bytes)
- * Return: 0 if OK, 1 on error
+ * Return: 0 if OK, -ve on error

env_set() will return 1 in case of an error. So how about:

Quoted 1 line

Return: 0 if OK, non-zero otherwise

Fixed.

This part of the api is really awfully confusing when it comes to return codes, sigh ...