tools/libxc: Correct read_exact() error messages
PATCH 1/1 tools/libxc: Correct read_exact() error messages
The errors have been incorrectly identifying their function since c/s 861aef6e1558bebad8fc60c1c723f0706fd3ed87 which did a lot of error handling cleanup.
Use __func__ to ensure the name remains correct in the future.
--- tools/libxc/xc_domain_restore.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/libxc/xc_domain_restore.c +2 -2
@@ -87,7 +87,7 @@ static ssize_t rdexact(xc_interface *xch, struct restore_ctx *ctx,if ( len ==-1 && errno ==EINTR )continue ;if ( !FD_ISSET (fd, &rfds) ) { -ERROR ("read_exact_timed failed (select returned %zd)" , len); +ERROR ("%s failed (select returned %zd)" , __func__, len); errno =ETIMEDOUT ;return -1 ; }
@@ -101,7 +101,7 @@ static ssize_t rdexact(xc_interface *xch, struct restore_ctx *ctx, errno =0 ; }if ( len <=0 ) { -ERROR ("read_exact_timed failed (read rc: %d, errno: %d)" , len, errno); +ERROR ("%s failed (read rc: %d, errno: %d)" , __func__, len, errno);return -1 ; } offset += len;
Signature · 1 line
1.7.10.4
Quoted 9 lines · Andrew Cooper
The errors have been incorrectly identifying their function since c/s
861aef6e1558bebad8fc60c1c723f0706fd3ed87which did a lot of error handling cleanup.Use
__func__to ensure the name remains correct in the future.Signed-off-by Andrew Cooper <[email protected]>CC Ian Campbell <[email protected]>CC Ian Jackson <[email protected]>
A simple string change seems harmless from a release PoV, so on that front
Release-Acked-by: Ian Campbell.
For the actual change though, most uses of ERROR in this function just have a descriptive error without the function name. If we are going to change it then I'm not convinced "rdexact failed..." is as useful as something like "Failed to read exactly %d bytes (select returned...)". Other thoughts?
(that said, I'm still somewhat inclined to just bung this one in...)
Ian.
Quoted 26 lines
--- tools/libxc/xc_domain_restore.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)tools/libxc/xc_domain_restore.c +2
-2@@ -87,7 +87,7 @@ static ssize_t rdexact(xc_interface *xch, struct restore_ctx *ctx,if ( len ==-1 && errno ==EINTR )continue ;if ( !FD_ISSET (fd, &rfds) ) { -ERROR ("read_exact_timed failed (select returned %zd)" , len); +ERROR ("%s failed (select returned %zd)" , __func__, len); errno =ETIMEDOUT ;return -1 ; }@@ -101,7 +101,7 @@ static ssize_t rdexact(xc_interface *xch, struct restore_ctx *ctx, errno =0 ; }if ( len <=0 ) { -ERROR ("read_exact_timed failed (read rc: %d, errno: %d)" , len, errno); +ERROR ("%s failed (read rc: %d, errno: %d)" , __func__, len, errno);return -1 ; } offset += len;
Quoted 20 lines · Ian Campbell
Quoted 9 lines · Andrew Cooper
The errors have been incorrectly identifying their function since c/s
861aef6e1558bebad8fc60c1c723f0706fd3ed87which did a lot of error handling cleanup.Use
__func__to ensure the name remains correct in the future.Signed-off-by Andrew Cooper <[email protected]>CC Ian Campbell <[email protected]>CC Ian Jackson <[email protected]>A simple string change seems harmless from a release PoV, so on that front
Release-Acked-by: Ian Campbell.For the actual change though, most uses of ERROR in this function just have a descriptive error without the function name. If we are going to change it then I'm not convinced "rdexact failed..." is as useful as something like "Failed to read exactly %d bytes (select returned...)". Other thoughts?
Quoted 3 lines
(that said, I'm still somewhat inclined to just bung this one in...)
Ian.
When triaging problems after-the-fact from logfiles along, a lack of file/line/function references is often makes debugging harder than it should be.
In the specific case I encountered, the error as was sufficed for working out what had gone wrong (an -EIO).
I would possibly throw it straight in now, with a note that there needs to be some consistency applied to the error reporting in this and other areas of libxc.
~Andrew
Quoted 8 lines · Andrew Cooper
The errors have been incorrectly identifying their function since c/s
861aef6e1558bebad8fc60c1c723f0706fd3ed87which did a lot of error handling cleanup.Use
__func__to ensure the name remains correct in the future.Signed-off-by Andrew Cooper <[email protected]>CC Ian Campbell <[email protected]>
Acked + applied, thanks.
Ian Campbell writes ("Re: [Xen-devel] [Patch] tools/libxc: Correct read_exact() error messages"):
Quoted 11 lines · Andrew Cooper
Quoted 8 lines
The errors have been incorrectly identifying their function since c/s
861aef6e1558bebad8fc60c1c723f0706fd3ed87which did a lot of error handling cleanup.Use
__func__to ensure the name remains correct in the future.Signed-off-by Andrew Cooper <[email protected]>CC Ian Campbell <[email protected]>Acked + applied, thanks.
Backported to 4.3 and 4.2.
Ian.