On 2014/11/1 23:18, Eric Blake wrote:
On 10/31/2014 07:50 PM, zhanghailiang wrote:
Convert several Character backend open functions to use the Error API.

Signed-off-by: zhanghailiang <zhang.zhanghaili...@huawei.com>
---
  qemu-char.c | 52 +++++++++++++++++++++++++++-------------------------
  1 file changed, 27 insertions(+), 25 deletions(-)

@@ -2337,12 +2339,12 @@ static CharDriverState 
*qemu_chr_open_stdio(ChardevStdio *opts)
          if (stdio->hInputThread == INVALID_HANDLE_VALUE
              || stdio->hInputReadyEvent == INVALID_HANDLE_VALUE
              || stdio->hInputDoneEvent == INVALID_HANDLE_VALUE) {
-            fprintf(stderr, "cannot create stdio thread or event\n");
+            error_setg(errp, "cannot create stdio thread or event");
              exit(1);

This conversion feels wrong.  error_setg() does not report an error, it
just stores the error for a later entity higher in the call stack to
report it.  But exit() means there is no execution of the reporting

OK, I got it, thanks for your explanation;)

code.  Either leave this one alone, or get rid of the exit and instead
properly propagate error status back to the caller and make sure the
caller reports it.


I will keep the exit, but use error_report instead, as other places in 
qemu.,thanks.



Reply via email to