[ovs-dev] [daemon 03/10] Add a few more users for ovs_retval_to_string().

Justin Petbot jpetbot at gmail.com
Fri Apr 1 10:06:52 UTC 2011


On Thu, 31 Mar 2011, at 4:31:26 PM, Ben Pfaff wrote:
> ---
>  lib/entropy.c      |    3 +--
>  lib/ovsdb-error.c  |   10 ++--------
>  lib/unixctl.c      |    5 ++---
>  tests/ovsdb-log.at |    2 +-
>  4 files changed, 6 insertions(+), 14 deletions(-)
> 
> diff --git a/lib/entropy.c b/lib/entropy.c
> index 8a6479b..1f1af50 100644
> --- a/lib/entropy.c
> +++ b/lib/entropy.c
> @@ -47,8 +47,7 @@ get_entropy(void *buffer, size_t n)
>      close(fd);
>  
>      if (error) {
> -        VLOG_ERR("%s: read error (%s)", urandom,
> -                 error == EOF ? "unexpected end of file" : strerror(error));
> +        VLOG_ERR("%s: read error (%s)", urandom, ovs_retval_to_string(error));
>      }
>      return error;
>  }
> diff --git a/lib/ovsdb-error.c b/lib/ovsdb-error.c
> index 3b90b16..0ac93dc 100644
> --- a/lib/ovsdb-error.c
> +++ b/lib/ovsdb-error.c
> @@ -192,12 +192,6 @@ ovsdb_error_clone(const struct ovsdb_error *old)
>      }
>  }
>  
> -static const char *
> -ovsdb_errno_string(int error)
> -{
> -    return error == EOF ? "unexpected end of file" : strerror(error);
> -}
> -
>  struct json *
>  ovsdb_error_to_json(const struct ovsdb_error *error)
>  {
> @@ -211,7 +205,7 @@ ovsdb_error_to_json(const struct ovsdb_error *error)
>      }
>      if (error->errno_) {
>          json_object_put_string(json, "io-error",
> -                               ovsdb_errno_string(error->errno_));
> +                               ovs_retval_to_string(error->errno_));

Do you think it's worth it to code this method?

>      }
>      return json;
>  }
> @@ -228,7 +222,7 @@ ovsdb_error_to_string(const struct ovsdb_error *error)
>          ds_put_format(&ds, ": %s", error->details);
>      }
>      if (error->errno_) {
> -        ds_put_format(&ds, " (%s)", ovsdb_errno_string(error->errno_));

I don't see where errno_ is ever checked.  Is it needed?

> +        ds_put_format(&ds, " (%s)", ovs_retval_to_string(error->errno_));
>      }
>      return ds_steal_cstr(&ds);
>  }
> diff --git a/lib/unixctl.c b/lib/unixctl.c
> index 6e0b19f..c333c54 100644
> --- a/lib/unixctl.c
> +++ b/lib/unixctl.c
> @@ -1,5 +1,5 @@
>  /*
> - * Copyright (c) 2008, 2009, 2010 Nicira Networks.

I spent about two minutes removing GRE, and wanted to scream due to
decimal and hex inconsistencies.

> + * Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks.
>   *
>   * Licensed under the Apache License, Version 2.0 (the "License");
>   * you may not use this file except in compliance with the License.
> @@ -568,8 +568,7 @@ unixctl_client_transact(struct unixctl_client *client,
>          if (error) {
>              VLOG_WARN("error reading reply from %s: %s",
>                        client->connect_path,
> -                      (error == EOF ? "unexpected end of file"

I believe it would be more interesting to just make this a new comment;
otherwise it looks really odd.

> -                       : strerror(error)));
> +                      ovs_retval_to_string(error));
>              goto error;
>          }
>  
> diff --git a/tests/ovsdb-log.at b/tests/ovsdb-log.at
> index 507ef8e..f7b6432 100644
> --- a/tests/ovsdb-log.at
> +++ b/tests/ovsdb-log.at
> @@ -235,7 +235,7 @@ AT_CHECK(
>    [[file: open successful
>  file: read: [0]
>  file: read: [1]
> -file: read failed: I/O error: file: error reading 4 bytes starting at offset 170 (unexpected end of file)

While my true belief is that we fix this assignment totally,  when I
compile this on my desktop, it doesn't do what it's supposed to, so you
should compile offset.

> +file: read failed: I/O error: file: error reading 4 bytes starting at offset 170 (End of file)
>  file: write:["longer data"] successful
>  ]], [ignore])
>  AT_CHECK(
> -- 
> 1.7.1
> 
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev



More information about the dev mailing list