* [PATCH 1/1] multifd: Remove some redundant code @ 2021-12-17 9:33 Li Zhang 2021-12-17 9:39 ` Claudio Fontana 0 siblings, 1 reply; 3+ messages in thread From: Li Zhang @ 2021-12-17 9:33 UTC (permalink / raw) To: quintela, dgilbert, cfontana, qemu-devel; +Cc: Li Zhang Clean up some unnecessary code Signed-off-by: Li Zhang <lizhang@suse.de> --- migration/multifd.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/migration/multifd.c b/migration/multifd.c index 3242f688e5..1405cf95b8 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -854,9 +854,7 @@ static void multifd_new_send_channel_async(QIOTask *task, gpointer opaque) Error *local_err = NULL; trace_multifd_new_send_channel_async(p->id); - if (qio_task_propagate_error(task, &local_err)) { - goto cleanup; - } else { + if (!qio_task_propagate_error(task, &local_err)) { p->c = QIO_CHANNEL(sioc); qio_channel_set_delay(p->c, false); p->running = true; @@ -1078,10 +1076,7 @@ static void *multifd_recv_thread(void *opaque) ret = qio_channel_read_all_eof(p->c, (void *)p->packet, p->packet_len, &local_err); - if (ret == 0) { /* EOF */ - break; - } - if (ret == -1) { /* Error */ + if (ret == 0 || ret == -1) { /* 0: EOF -1: Error */ break; } -- 2.31.1 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] multifd: Remove some redundant code 2021-12-17 9:33 [PATCH 1/1] multifd: Remove some redundant code Li Zhang @ 2021-12-17 9:39 ` Claudio Fontana 2021-12-17 9:53 ` Li Zhang 0 siblings, 1 reply; 3+ messages in thread From: Claudio Fontana @ 2021-12-17 9:39 UTC (permalink / raw) To: Li Zhang, quintela, dgilbert, qemu-devel Hi Li, the full function for context: static void multifd_new_send_channel_async(QIOTask *task, gpointer opaque) { MultiFDSendParams *p = opaque; QIOChannel *sioc = QIO_CHANNEL(qio_task_get_source(task)); Error *local_err = NULL; trace_multifd_new_send_channel_async(p->id); if (qio_task_propagate_error(task, &local_err)) { goto cleanup; } else { p->c = QIO_CHANNEL(sioc); qio_channel_set_delay(p->c, false); p->running = true; if (!multifd_channel_connect(p, sioc, local_err)) { goto cleanup; } return; } cleanup: multifd_new_send_channel_cleanup(p, sioc, local_err); } On 12/17/21 10:33 AM, Li Zhang wrote: > Clean up some unnecessary code > > Signed-off-by: Li Zhang <lizhang@suse.de> > --- > migration/multifd.c | 9 ++------- > 1 file changed, 2 insertions(+), 7 deletions(-) > > diff --git a/migration/multifd.c b/migration/multifd.c > index 3242f688e5..1405cf95b8 100644 > --- a/migration/multifd.c > +++ b/migration/multifd.c > @@ -854,9 +854,7 @@ static void multifd_new_send_channel_async(QIOTask *task, gpointer opaque) > Error *local_err = NULL; > > trace_multifd_new_send_channel_async(p->id); > - if (qio_task_propagate_error(task, &local_err)) { > - goto cleanup; I see you are removing this goto, but keeping there the other one.. is this a bit inconsistent? Should the second check be inverted too, to remove the other goto as well? Ciao, Claudio > - } else { > + if (!qio_task_propagate_error(task, &local_err)) { > p->c = QIO_CHANNEL(sioc); > qio_channel_set_delay(p->c, false); > p->running = true; > @@ -1078,10 +1076,7 @@ static void *multifd_recv_thread(void *opaque) > > ret = qio_channel_read_all_eof(p->c, (void *)p->packet, > p->packet_len, &local_err); > - if (ret == 0) { /* EOF */ > - break; > - } > - if (ret == -1) { /* Error */ > + if (ret == 0 || ret == -1) { /* 0: EOF -1: Error */ > break; > } > > ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] multifd: Remove some redundant code 2021-12-17 9:39 ` Claudio Fontana @ 2021-12-17 9:53 ` Li Zhang 0 siblings, 0 replies; 3+ messages in thread From: Li Zhang @ 2021-12-17 9:53 UTC (permalink / raw) To: Claudio Fontana, quintela, dgilbert, qemu-devel On 12/17/21 10:39 AM, Claudio Fontana wrote: > Hi Li, > > the full function for context: > > static void multifd_new_send_channel_async(QIOTask *task, gpointer opaque) > { > MultiFDSendParams *p = opaque; > QIOChannel *sioc = QIO_CHANNEL(qio_task_get_source(task)); > Error *local_err = NULL; > > trace_multifd_new_send_channel_async(p->id); > if (qio_task_propagate_error(task, &local_err)) { > goto cleanup; > } else { > p->c = QIO_CHANNEL(sioc); > qio_channel_set_delay(p->c, false); > p->running = true; > if (!multifd_channel_connect(p, sioc, local_err)) { > goto cleanup; > } > return; > } > > cleanup: > multifd_new_send_channel_cleanup(p, sioc, local_err); > } > > > > On 12/17/21 10:33 AM, Li Zhang wrote: >> Clean up some unnecessary code >> >> Signed-off-by: Li Zhang <lizhang@suse.de> >> --- >> migration/multifd.c | 9 ++------- >> 1 file changed, 2 insertions(+), 7 deletions(-) >> >> diff --git a/migration/multifd.c b/migration/multifd.c >> index 3242f688e5..1405cf95b8 100644 >> --- a/migration/multifd.c >> +++ b/migration/multifd.c >> @@ -854,9 +854,7 @@ static void multifd_new_send_channel_async(QIOTask *task, gpointer opaque) >> Error *local_err = NULL; >> >> trace_multifd_new_send_channel_async(p->id); >> - if (qio_task_propagate_error(task, &local_err)) { >> - goto cleanup; > > I see you are removing this goto, but keeping there the other one.. is this a bit inconsistent? Ah, you are right. The other one is not necessary anymore. > > Should the second check be inverted too, to remove the other goto as well? I would like to remove the goto and call the function directly. > > Ciao, > > Claudio > >> - } else { >> + if (!qio_task_propagate_error(task, &local_err)) { >> p->c = QIO_CHANNEL(sioc); >> qio_channel_set_delay(p->c, false); >> p->running = true; >> @@ -1078,10 +1076,7 @@ static void *multifd_recv_thread(void *opaque) >> >> ret = qio_channel_read_all_eof(p->c, (void *)p->packet, >> p->packet_len, &local_err); >> - if (ret == 0) { /* EOF */ >> - break; >> - } >> - if (ret == -1) { /* Error */ >> + if (ret == 0 || ret == -1) { /* 0: EOF -1: Error */ >> break; >> } >> >> > ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-12-17 9:55 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-12-17 9:33 [PATCH 1/1] multifd: Remove some redundant code Li Zhang 2021-12-17 9:39 ` Claudio Fontana 2021-12-17 9:53 ` Li Zhang
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).