xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH for-4.14 v2] tools/xen-ucode: fix error code propagation of microcode load operation
@ 2020-06-16 11:42 Igor Druzhinin
  2020-06-16 12:25 ` Jan Beulich
  0 siblings, 1 reply; 3+ messages in thread
From: Igor Druzhinin @ 2020-06-16 11:42 UTC (permalink / raw)
  To: xen-devel; +Cc: Igor Druzhinin, ian.jackson, xadimgnik, wl

Otherwise it's impossible to know the reason for a fault or blob rejection
inside the automation.

While at it, also change return code of incorrect invokation to EINVAL.

Signed-off-by: Igor Druzhinin <igor.druzhinin@citrix.com>
---
Changes in v2:
- simply call "return errno". On Linux that seems to be safe as values <=255
  are correctly propagated, on non-Linux I couldn't find error codes >127.
- return positive value on incorrect invokation
---
 tools/misc/xen-ucode.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/misc/xen-ucode.c b/tools/misc/xen-ucode.c
index 0c257f4..409cace 100644
--- a/tools/misc/xen-ucode.c
+++ b/tools/misc/xen-ucode.c
@@ -25,7 +25,7 @@ int main(int argc, char *argv[])
         fprintf(stderr,
                 "xen-ucode: Xen microcode updating tool\n"
                 "Usage: %s <microcode blob>\n", argv[0]);
-        return 0;
+        return EINVAL;
     }
 
     filename = argv[1];
@@ -62,8 +62,11 @@ int main(int argc, char *argv[])
 
     ret = xc_microcode_update(xch, buf, len);
     if ( ret )
+    {
         fprintf(stderr, "Failed to update microcode. (err: %s)\n",
                 strerror(errno));
+        return errno;
+    }
 
     xc_interface_close(xch);
 
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH for-4.14 v2] tools/xen-ucode: fix error code propagation of microcode load operation
  2020-06-16 11:42 [PATCH for-4.14 v2] tools/xen-ucode: fix error code propagation of microcode load operation Igor Druzhinin
@ 2020-06-16 12:25 ` Jan Beulich
  2020-06-16 12:40   ` Igor Druzhinin
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Beulich @ 2020-06-16 12:25 UTC (permalink / raw)
  To: Igor Druzhinin; +Cc: xen-devel, ian.jackson, wl, xadimgnik

On 16.06.2020 13:42, Igor Druzhinin wrote:
> @@ -62,8 +62,11 @@ int main(int argc, char *argv[])
>  
>      ret = xc_microcode_update(xch, buf, len);
>      if ( ret )
> +    {
>          fprintf(stderr, "Failed to update microcode. (err: %s)\n",
>                  strerror(errno));
> +        return errno;

I think you need to latch errno, as fprintf() may in principle run
into another error.

Jan


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH for-4.14 v2] tools/xen-ucode: fix error code propagation of microcode load operation
  2020-06-16 12:25 ` Jan Beulich
@ 2020-06-16 12:40   ` Igor Druzhinin
  0 siblings, 0 replies; 3+ messages in thread
From: Igor Druzhinin @ 2020-06-16 12:40 UTC (permalink / raw)
  To: Jan Beulich; +Cc: xen-devel, ian.jackson, wl, xadimgnik

On 16/06/2020 13:25, Jan Beulich wrote:
> [CAUTION - EXTERNAL EMAIL] DO NOT reply, click links, or open attachments unless you have verified the sender and know the content is safe.
> 
> On 16.06.2020 13:42, Igor Druzhinin wrote:
>> @@ -62,8 +62,11 @@ int main(int argc, char *argv[])
>>  
>>      ret = xc_microcode_update(xch, buf, len);
>>      if ( ret )
>> +    {
>>          fprintf(stderr, "Failed to update microcode. (err: %s)\n",
>>                  strerror(errno));
>> +        return errno;
> 
> I think you need to latch errno, as fprintf() may in principle run
> into another error.

Yes, I also noticed that but the whole file has this problem so I didn't
change it here specifically.

If fixing the whole file - I'd rather rewrite error reporting completely:
return 1 on error, 0 on success, etc. From what I've read returning errno
has many incompatibilities and might lead to surprise consequences.

I'll send v3 to clean this all up.

Igor


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-06-16 12:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-16 11:42 [PATCH for-4.14 v2] tools/xen-ucode: fix error code propagation of microcode load operation Igor Druzhinin
2020-06-16 12:25 ` Jan Beulich
2020-06-16 12:40   ` Igor Druzhinin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).