On Thu, Mar 15, 2007 at 02:53:38PM +0530, Vivek Goyal wrote: > On Thu, Mar 15, 2007 at 06:11:55PM +0900, Magnus Damm wrote: > > On Thu, 2007-03-15 at 14:30 +0530, Vivek Goyal wrote: > > > On Thu, Mar 15, 2007 at 05:53:19PM +0900, Magnus Damm wrote: > > > > Move memory range variables > > > > > > > > The common kexec code is currently using two global variables to keep > > > > track of memory ranges. Other data is kept in a per-instance structure. > > > > This mix is of per-instance and global variables is confusing and leads > > > > to messy code in general. So let's not. > > > > > > > > > > These two variable are static and limited to usage by this file only. > > > Moving to kexec_info makes them visible to everybody and they don't have > > > to. > > > > > > Not sure how does it make code better. I think we don't have to do this. > > > > Haha, I _knew_ that you would say that. =) > > > > Yes, the variables are limited to that file only. But I do think it is > > bad coding practice to use a mix of static/global and per-instance > > variables. And it is being done all over kexec-tools. > > > > Such coding practice IMO leads to messy code and people cooking pasta by > > calling stuff from everywhere. For instance, try to follow the setup and > > use of the structure memory_range in kexec-ia64.c. It's a mess. > > That's fine but that's the fundamental difference between global variables > and static global variables. What you seem to be suggesting that lets take > out all the static global variables and make them pure global by putting > in a common structure which is passed around. IMHO, does not make much > sense to me. If some variables are limited to a file and not truly global, > we don't have to make them visible to everybody. This will also lead to > unrequired burden on stack as so many functions pass around kexec_info. > > What others think?
I don't think that elements of a structure that is passed around can be accurately described as global variables. Sure, the former may end up being accessable by a lot of functions. Perhaps a lot of functions that wouldn't have access to them if they were "static global". But a fundamental difference is that if you pass a structure around, you can have mutiple instances of it. Which is clearly not possible with global or "static global". Another fundamental difference is that by passing values around, the API defines the scoping of the values, but with "static global" scoping is controled by the file locality. Enough about terminology. I am definately of the school of thought that putting all the varaibles in one place - in this case a structure - is a great improvement over having some stuff in a structure and some stuff in global variables. -- Horms H: http://www.vergenet.net/~horms/ W: http://www.valinux.co.jp/en/ _______________________________________________ fastboot mailing list [email protected] https://lists.osdl.org/mailman/listinfo/fastboot
