From mboxrd@z Thu Jan 1 00:00:00 1970 From: pierre-marc.fournier@polymtl.ca (Pierre-Marc Fournier) Date: Sun, 05 Sep 2010 21:03:39 -0400 Subject: [ltt-dev] [UST PATCH] remove duplicate return In-Reply-To: <20100906004907.GB14418@Krystal> References: <1283729203-4435-1-git-send-email-douglas.santos@polymtl.ca> <20100906004907.GB14418@Krystal> Message-ID: <1283735019.1893.3.camel@Nokia-N900-42-11> I disagree with you Mathieu. These retvals are the same as i/o syscalls (read/write/send/recv/...)and therefore should in my opinion remain as is. pmf ----- Original message ----- > * Douglas Santos (douglas.santos at polymtl.ca) wrote: > > --- > > libustcmd/ustcmd.c |? ? ? 5 ----- > > 1 files changed, 0 insertions(+), 5 deletions(-) > > > > diff --git a/libustcmd/ustcmd.c b/libustcmd/ustcmd.c > > index cf6b9d7..825a649 100644 > > --- a/libustcmd/ustcmd.c > > +++ b/libustcmd/ustcmd.c > > @@ -381,11 +381,6 @@ int ustcmd_get_cmsf(struct marker_status **cmsf, > > const pid_t pid)??? ??? return -1; > > ??? } > > > > -??? if (result != 1) { > > -??? ??? ERR("error while getting markers list"); > > -??? ??? return -1; > > -??? } > > Looks good, so > > Acked-by Mathieu Desnoyers > > but why on earth is ustcomm_send_request() returning: > > /* >? * Return value: >? *? ? 0: Success, but no reply because recv() returned 0 >? *? ? 1: Success >? *? ? -1: Error >? * >? * On error, the error message is printed, except on >? * ECONNRESET, which is normal when the application dies. >? */ > > Typical return values everywhere else in the project, in the Linux > kernel, and in libs are: > > 0: success > negative: errors. > positive: used for a quantity counter > > So for ustcomm_send_request(), I recommend to remap the "return 0" to > "return -ENODATA".? And to remap "return 1" to return 0, and update all > callers to test for if (ret < 0) rather than if (ret != 1). > > If you ever need inspiration for error values, please refer to > /usr/include/asm-generic/errno-base.h and > /usr/include/asm-generic/errno.h > > Thanks, > > Mathieu > > > > - > > ??? tmp_cmsf = (struct marker_status *) malloc(sizeof(struct > > marker_status) *??? ??? (ustcmd_count_nl(big_str) + 1)); > > ??? if (tmp_cmsf == NULL) { > > -- > > 1.7.0.4 > > > > > > _______________________________________________ > > ltt-dev mailing list > > ltt-dev at lists.casi.polymtl.ca > > http://lists.casi.polymtl.ca/cgi-bin/mailman/listinfo/ltt-dev > > > > -- > Mathieu Desnoyers > Operating System Efficiency R&D Consultant > EfficiOS Inc. > http://www.efficios.com > > _______________________________________________ > ltt-dev mailing list > ltt-dev at lists.casi.polymtl.ca > http://lists.casi.polymtl.ca/cgi-bin/mailman/listinfo/ltt-dev