[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH v4 05/14] golang/xenlight: Add tests host related functionality functions
On Mon, Mar 20, 2017 at 6:15 PM, Ian Jackson <ian.jackson@xxxxxxxxxxxxx> wrote: > George Dunlap writes ("Re: [Xen-devel] [PATCH v4 05/14] golang/xenlight: Add > tests host related functionality functions"): >> I had a chat with Ian Jackson, and we agreed that it would be better >> to create a file, maybe "test-common.c", that would contain this >> variable, as well as the three functions below. >> >> Then the header ("test-common.h") would contain *declarations* of the >> variable (i.e., "extern xentoollog_logger_stdiostream *logger;") and >> function prototypes. >> >> The test-common.c file is small now, but it may grow as additional >> functionality is needed. > > Right. > >> The other thing you might consider, to further reduce the boilerplate >> you have in each unit test file, is to also include a libxl_ctx >> pointer in test-common; and have create_context() simply return an int >> (0 for success, -1 for failure). > > This would be nice. > > You might also consider whether create_context would better simply > exit the program if it fails. That avoids any possibility of error > handling bugs. And maybe it should be called test_common_setup() ? > (Names are a matter of taste, though.) > > Also: in C, main needs to return a value. I'm surprised your compiler > isn't complaining. (Are the compiler warnings properly enabled?) I > think I mentioned this one before... Actually I think in C if you don't call 'return', you end up getting whatever the last value that was calculated as a return value instead. At least I once had a colleague show me a program and ask, "Wait, why does this work?" when he wrote a function that did a bunch of calculations but never called return. :-) Better to be explicit though. -George _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |