> 2006-08-02: Bob Copeland dixit:
> > No, it should be changed to
> >
> > if (karma < 0) {
> > ...
> > }
>
> Why? It is redundant as you already have lk_errors_p("","")
> before. You may add some text instead of "" if you are not
> content with the standard lk_errors message...
My mistake, I thought that was the only error path there, but I see that
there's another if (karma < 0) right after that. I suspect it was added
because the USB side of the house doesn't set an error if "connect" fails.
This whole section of code is a mess:
if (!host) {
[print some stuff and exit]
}
if (host != NULL) { // <- always true, so why test?
Should look more like:
if (!host) {
lk_errors_p(...);
usage(0);
goto cleanup;
}
karma = lk_karma_connect(host);
lk_errors_p(...);
free(host);
if (karma < 0)
goto cleanup;
[do stuff]
cleanup:
free(blah);
Gotos are ugly and all that, but this way you don't miss a free(). I'll
work up a patch if no one gets to it first.
--
Bob Copeland %% www.bobcopeland.com
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
linux-karma-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-karma-devel