From mboxrd@z Thu Jan 1 00:00:00 1970 From: mathieu.desnoyers@efficios.com (Mathieu Desnoyers) Date: Tue, 26 Jun 2012 02:00:43 -0400 Subject: [lttng-dev] [PATCH 2/2] liblttng-ust-comm/lttng-ust-com.c: remove unnecessary goto in ustcomm_accept_unix_sock() In-Reply-To: <1340623371-22228-2-git-send-email-henrik@fiktivkod.org> References: <1340623371-22228-1-git-send-email-henrik@fiktivkod.org> <1340623371-22228-2-git-send-email-henrik@fiktivkod.org> Message-ID: <20120626060043.GB11445@Krystal> * Henrik Hautakoski (henrik at fiktivkod.org) wrote: > Signed-off-by: Henrik Hautakoski In this specific case, this is right that the goto appears to be really useless. Although I would not merge this kind of change in all cases: if in another situation the function appears to be bound to have other calls in the future, using gotos allow to do the teardown of the function in error cases in a symmetric way: a = fct(); if (!a) goto error_a; b = fct2(); if (!b) goto error_b; return 0; /* OK */ error_b: teardown(a); error_a: return -1; So the intend in ustcomm_accept_unix_sock() was to ensure that as the function grows to contain more calls, the teardown can be done symmetrically in this way. But I guess it appears that it won't grow, so I'm taking the cleanup. Thanks, Mathieu > --- > liblttng-ust-comm/lttng-ust-comm.c | 6 +----- > 1 file changed, 1 insertion(+), 5 deletions(-) > > diff --git a/liblttng-ust-comm/lttng-ust-comm.c b/liblttng-ust-comm/lttng-ust-comm.c > index 078b56a..1e2fd1a 100644 > --- a/liblttng-ust-comm/lttng-ust-comm.c > +++ b/liblttng-ust-comm/lttng-ust-comm.c > @@ -172,13 +172,9 @@ int ustcomm_accept_unix_sock(int sock) > new_fd = accept(sock, (struct sockaddr *) &sun, &len); > if (new_fd < 0) { > perror("accept"); > - goto error; > + return -1; > } > - > return new_fd; > - > -error: > - return -1; > } > > /* > -- > 1.7.9.5 > > > _______________________________________________ > lttng-dev mailing list > lttng-dev at lists.lttng.org > http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev -- Mathieu Desnoyers Operating System Efficiency R&D Consultant EfficiOS Inc. http://www.efficios.com