Thursday, December 14, 2017

Digital Cartography

With nearly 1000 warnings to have to go though, I decided to turn on Doxygen's graphing system to help map out ROE. What I got back after about three minutes of number crunching was an unexpected surprise! Turns out it can generate really awesome call and caller maps. The means I can trace backwards from any call and go forward downstream. I can also find functions and where they are placed in the grand scheme of things. No more having to manually search and backtrack though the code manually. Some of the call paths are super wild, but that's what happens with spaghetti code sometimes. I included a map for the SetupEnemyForm() function that takes all the bits of aliens (arms, legs, head) and generates a graphical representation of the alien you are fighting in the game. As you can see, the execution path is as clear as a bell. I am so stoked about this.


I also decided to turn off the suppression of unsafe functions. (i.e. have the system generate an error  when it comes across a function that is prone to a buffer overrun). This resulted in 504 errors and another 3 warnings. I turned the suppression back on, and will deal with that later.So now I can go in a bunch of different directions. Now that I have a map, let's start to categorize those warnings and what I need to do about them. Using the magic of a spreadsheet and pivot table, I only have 11 types of warnings:


  1. <function> undefined; assuming extern returning int  (603 Warnings)
    1. Pie graph of all warnings
    2.  I have not included rproto.h into the main code yet. This has all the prototypes that need to be set during compile. However, my C++ compiler seem to be prototyping on the fly, I need to put the horse before the cart here and integrate rproto.h properly 
  2.  <expression>: signed/unsigned mismatch (20 Warnings)
    1. C++ has a type that is not in C called size_t, which is a unsigned int. There are several common functions such as strlen() that used to return type int that now return type size_t, which is unsigned. strlen() is also one of those functions that should be an error as it's not safe (Should be using strnlen_s()) so each function with this warning will need to be checked to make sure the variable can't go negative, and if it doesn't type it to an unsigned int
  3.   <function> : too many actual parameters (1 Warning) 
    1. I think this is a bad placeholder file function I put in. Will be converting this to AllegroFS anyway
  4.  <function> : different types for formal and actual parameter 'number' (1 Warning)
    1. Another type mismatch. I'll have to find it correct.
  5.  <identifier1> : 'operator' : different levels of indirection from 'identifier2' (3 Warnings)
    1. There is some hinky pointers referencing in funny ways. Will investigate. 
  6.  <identifier> : unreferenced local variable (241 Warnings)
    1. This is actually pretty easy. There are unused variables. Purge them if not needed.
  7.  <identifier1> differs in parameter lists from 'identifier2' (1 Warning)
    1. I have a function that is mismatching - Find and fix.
  8.  <var> : conversion from 'size_t' to 'type', possible loss of data (1 Warning)
    1. size_t again, I'm guessing that my 4 byte int is not fitting in somewhere
  9.  <function> : not enough arguments passed for format string (1 Warning)
    1. Another string function - those are going to get scrutinized 
  10.  <function> : not all control paths return a value (30 Warnings)
    1. Check execution paths. 
  11.  <function> must return a value (48 Warnings)
    1. Bad prototype, Check definitions



So Not bad, The "Big ones" is just janitorial work mostly type fixing and making sure functions match with how they are being called.  So the plan so far is to get the warnings squashed, Check for graphical bugs in Nermal, replace the 504 insecure functions, and move the filesystem functions into Allegro... I like that as a plan so far!

No comments:

Post a Comment