remove opt_nocopyzero setting globally, since unused#2187
remove opt_nocopyzero setting globally, since unused#2187ghaerr merged 2 commits intoghaerr:masterfrom
Conversation
|
Hi @floriangit, I think we've had a miscommunication - the Thank you! |
|
Oops, ok. I guess I interpreted your "global" remark as a too strong hint then ;-) For the genfs.c change, which is almost same as cp.c you want to keep the removal, or not? It will be always 0 anyhow same as in cp.c? Thanks |
Lets clear up confusion regarding "extern int opt_nocopyzero" and "int opt_nocopyzero = 0" first. An extern int declaration by the C compiler does nothing other than enter the type and size into the symbol table, so that should the symbol be seen again, such as in genfs.c, the compiler knows the type and size to generate code for it. In mkfs.c, the variable itself is seen as both extern int from protos.h, and then declared with initialization to 0, which causes the compiler to emit a non-common global symbol in the .data segment. The option itself is used in genfs.c to implement the non-copy operation. So the extern declaration in protos.h, the initialization in mkfs.c, and the actual use in genfs.c are all required. We don't want to remove any of this, since mfs accepts a -k option which is used to not copy files with zero length. All the above code is in the tools/mfs/ directory is used to compile a completely separate host-based The cp.c code is entirely different, but looks the same, because it was copied from the mfs/ code when I was looking for a fast way to recursively traverse directories when implementing the cp -R option. What we are trying to do is to remove the code, in cp.c only, which you correctly identified as using an option that was never set. The cp.c code is never linked with the mfs code, it is used to build the ELKS
No, in the genfs,.c code, opt_nocopyzero will not always be zero - it will be 1 if the -k option is specified to Bottom line, the only file that should be changed is cp.c, removing the code which can't ever execute. As previously discussed, since the code used a global non-static variable, it will never be optimized out. |
|
Thank you @floriangit! |
: #2182