Daniel Veillard wrote: > On Wed, Sep 09, 2009 at 10:17:48AM +0200, Jim Meyering wrote: >> Jim Meyering wrote: >> ... >> > At Chris' suggestion, I've added a comment warning not to do what I did ;-) >> > >> > To make it even more obvious that these numbers matter, >> > I've assigned explicit constants in the enum: >> > >> > + QEMUD_SAVE_FORMAT_RAW = 0, >> > + QEMUD_SAVE_FORMAT_GZIP = 1, >> > + QEMUD_SAVE_FORMAT_BZIP2 = 2, >> > >> > Currently, if someone accidentally adds this (mistakenly reused number): >> > >> > + QEMUD_SAVE_FORMAT_OOPS = 2, >> > >> > the compiler won't catch it. >> > However, with a small additional change to use VIR_ENUM_DECL >> > and VIR_ENUM_IMPL, thus replacing the if/elsif/ chains, >> > and the compiler *would* detect that mistake. >> > It'd also help to factor out the QEMUD_SAVE_FORMAT_<> to "<>" >> > association, rather than having literals like "gzip" and "bzip2" >> > in two places. >> > >> > Now that I've described that, I'll prepare a separate patch. >> >> This depends on the preceding patch. > > yup using VIR_ENUM_IMPL, and VIR_ENUM_DECL is a good cleanup, > could you apply this to the current git, we will then reduce options > later, > > ACK, Thanks. Pushed that, along with the other ack'd changes. Note that that includes the one to use strchrnul, which required updated .gnulib/. And a .gnulib/ update requires that anyone building re-run ./autogen.sh. But don't worry: if anyone forgets, "make" will fail with a diagnostic telling them to do just that. -- Libvir-list mailing list Libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list