From mboxrd@z Thu Jan 1 00:00:00 1970 From: Hitoshi Mitake Subject: Re: [PATCH] mkfs: check sizes of important structs at build time Date: Mon, 06 Jan 2014 00:17:13 +0900 Message-ID: <87y52ua26e.wl%mitake.hitoshi@gmail.com> References: <1388842171-16105-1-git-send-email-mitake.hitoshi@gmail.com> <2276BC9A-0688-4566-8FA8-D280E6F71F5F@dubeyko.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Return-path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:message-id:from:to:cc:subject:in-reply-to:references :user-agent:mime-version:content-type; bh=N9C++PqgHmFEfyHR5tA7oVJw29nwOLUGCr+symgsNKI=; b=pEFfnF8JOrD2Oi4ieOx2LF38wLLFNOHZ/SQ/zhpACg2P3MqnmL75Qb8uRmDNOZIH+Y cpaFbbhPcXJpufP7Qtqas+3beB+G1FL704S2HbCxC5Ph/ODVxiYXP79BLoQlEwSerqli JbBgv/lQ6PRVIjhMHZ2J5QArJXdMGgO9CF7UIh2/Lox/1wOUTDuIcPiJlGskSxFbhhmn L1dN9J2rZbqa/5WJn7exuQtxA7T1jmHzW5nvabzLpo6fuayt3T7YkydEBlRS/IXU2eZX pgWSyK3M3tC321yRqUZMt11WeRn0gtz+mikjNnP9+f8yvIv/QIiwTClwFCuNcx1oCijb NUew== In-Reply-To: <2276BC9A-0688-4566-8FA8-D280E6F71F5F-yeENwD64cLxBDgjK7y7TUQ@public.gmane.org> Sender: linux-nilfs-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-ID: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Vyacheslav Dubeyko Cc: Hitoshi Mitake , linux-nilfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Hitoshi Mitake At Sat, 4 Jan 2014 18:39:58 +0300, Vyacheslav Dubeyko wrote: > > > On Jan 4, 2014, at 4:54 PM, Hitoshi Mitake wrote: > > > On Sat, Jan 4, 2014 at 11:52 PM, Vyacheslav Dubeyko 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 think that we can have only macro instead of the function nilfs_check_ondisk_sizes(). > And this macros can be placed in the begin of main() call. I think that it will be enough > for the compilation phase check. Ah, I see. > > >> > >> 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. > > > > I mean that block size can be different during volume creation and maybe > it makes sense to extend a block size related checking for run-time phase. > That's all. But right now I haven't any concrete suggestions. Currently, the check is comparison between sizes of important structs and the minimal block size. So we don't need a function for it. I think adding the function for runtime checking when nilfs requires it would be enough. Thanks, Hitoshi -- To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html