On Sat, Jan 4, 2014 at 11:52 PM, Vyacheslav Dubeyko <slava@xxxxxxxxxxx> wrote: > > On Jan 4, 2014, at 4:29 PM, Hitoshi Mitake wrote: > >> Current nilfs_check_ondisk_sizes() checks sizes of important structs >> at run time. The checking should be done at build time. This patch >> adds a new macro, BUILD_BUG_ON(), for this purpose. It is similar to >> static_assert() of C++11. If an argument is true, the macro causes a >> bulid error. >> >> Below is an example of BUILD_BUG_ON(). When the checked conditions are >> true like below: >> >> /* intentional change for testing BUILD_BUG_ON() */ >> >> static __attribute__((used)) void nilfs_check_ondisk_sizes(void) >> { >> BUILD_BUG_ON(sizeof(struct nilfs_inode) > NILFS_MIN_BLOCKSIZE); > > So, why do we need to have function for the case of checking on compilation > phase? Just for excluding the checking from other part of code and improve readability. > > I suppose that we need to have some run-time check anyway. Your approach > is correct for the current state of the code. But I feel a necessity in run-time check > anyway. Maybe it looks like a paranoia. :) Maybe it needs to extend checking > in this place. Do you mean both of the build time check and the run time check? If so, I agree with your opinion. I'll send v2 based on this policy. Thanks, Hitoshi -- To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html