<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Jul 14, 2013, at 04:01 , Vipul Nayyar <<a href="mailto:nayyar_vipul@yahoo.com">nayyar_vipul@yahoo.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div><div style="background-color: rgb(255, 255, 255); font-family: arial, helvetica, sans-serif; font-size: 10pt; position: static; z-index: auto; "><div><span>Hello,</span></div><div style="font-size: 13px; font-family: arial, helvetica, sans-serif; background-color: transparent; font-style: normal; "><span><br></span></div><div style="font-size: 13px; font-family: arial, helvetica, sans-serif; background-color: transparent; font-style: normal; "><span>While doing my current task of removing legacy code, after compilation, I receive warnings for a certain function, that is defined but not used. As suggested by Sebastian, I delete it, after checking whether it's really been not called anywhere in the current file, and outside it. Most of the functions that I'm talking about right now are static, or supposed to be static.</span></div><div style="font-size: 13px; font-family: arial, helvetica, sans-serif; background-color: transparent; font-style: normal; "><span><br></span></div><div style="font-size: 13px; font-family: arial, helvetica, sans-serif; background-color: transparent; font-style: normal; ">After re-compilation, warning for that deleted function is obviously gone, but there are new warnings of functions defined but not used. So, ultimately I have to delete these static functions who are inter-related(calling each other), in order to remove the warnings. Currently I was trying my hand on i386 pc386 BSP, where I encountered this thing. </div><div style="font-size: 13px; font-family: arial, helvetica, sans-serif; background-color: transparent; font-style: normal; "><br></div><div style="font-size: 13px; font-family: arial, helvetica, sans-serif; background-color: transparent; font-style: normal; ">I really don't know whether deleting these multiple inter-related static functions is the right way to
go or a horribly wrong one.</div><div style="font-size: 13px; font-family: arial, helvetica, sans-serif; background-color: transparent; font-style: normal; "><br></div><div style="font-size: 13px; font-family: arial, helvetica, sans-serif; background-color: transparent; font-style: normal; ">Hoping to hear soon.</div><div style="font-size: 13px; font-family: arial, helvetica, clean, sans-serif; background-color: transparent; font-style: normal; "><br></div><div style="font-size: 13px; font-family: arial, helvetica, clean, sans-serif; background-color: transparent; font-style: normal; ">Regards</div><div style="font-size: 13px; font-family: arial, helvetica, clean, sans-serif; background-color: transparent; font-style: normal; "><span style="background-color:transparent;line-height:1.22;">Vipul Nayyar </span></div><div style="font-size: 12.727272033691406px; font-family: arial, helvetica, clean, sans-serif; background-color: transparent; font-style: normal; "><br></div></div></div>_______________________________________________<br></blockquote></div><div apple-content-edited="true"><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; border-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; border-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="font-size: medium; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px; "><br></span></font></div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span style="font-size: 12px;">This is hard to answer. The question is whether the functionality that this is implementing is of any use in the future, as it apparently was of some use in the past.</span></div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span style="font-size: 12px;"><br></span></div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span style="font-size: 12px;">When confronted with this I usually choose a pre-processor define to associate with the static functions. Then I go through and conditionally disable the entire family of functions. After that I have a good understanding of its scope what it is doing, and I can then go and remove it completely or decide that there is some reason I still want to keep it around.</span></div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span style="font-size: 12px;"><br></span></div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span style="font-size: 12px;">If I do want to keep it around I do not leave conditionally compiled, completely unused code intact in a source files. Since it will never be compiled on RTEMS it will rot quickly and just become confusing, uncompilable cruft. </span></div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span style="font-size: 12px;"><br></span></div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span style="font-size: 12px;">However, let's say this code implements hooks for some sort of memory protection that it isn't implemented in RTEMS, but as we know there is work going on on this. So if I wanted to keep it around I would move the code to a new .c file, add a public interface so the static functions were used, remove the conditional compilation, and describe why I kept it and that it isn't really tested. It would then be compiled so it won't get any worse over time.</span></div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span style="font-size: 12px;"><br></span></div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span style="font-size: 12px;">The reason to move it to another file is so it </span><span style="font-size: 12px; ">is still compiled, but it</span><span style="font-size: 12px; "> won't increase code footprint. Many RTEMS applications are memory constrained.</span></div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span style="font-size: 12px;"><br></span></div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span style="font-size: 12px;">Joel might have a different answer. I know he is concerned with coverage and this complicates that.,</span></div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span style="font-size: 12px;"><br></span></div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span style="font-size: 12px;"> "The code already can't be trusted, it hasn't been used for who knows how long, remove it with extreme prejudice" is a much simpler and perfectly defendable answer.</span></div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span style="font-size: 12px;"><br></span></div><div style="font-size: medium; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px; ">Peter<br>-----------------<br>Peter Dufault<br>HD Associates, Inc. Software and System Engineering</span></font></div></span></span>
</div>
<br></body></html>