imageAnother tip of the cap to Nikolaj Schlej, this time for an interesting article where he examined the Intel Quark Board Support Package (BSP) source code with the static source code analyzer PVS-Studio.

The Intel Quark is an SoC used in embedded systems applications.  For example, it runs the Intel Galileo family of development boards.  Galileo is a small computer board comparable to the Arduino family of products, and is targeted to maker and educational customers.

The BSP is a set of documentation and EDKII source code that allows a developer to build his own bootable firmware image for the Quark.

Nikolaj discovered many serious problems, and I found it educational to read through them.  This is helpful so that you can discover the typical mistakes people make in UEFI development, and also so that you won’t make the same mistakes yourself!  I would summarize the problems in the source code in this manner:

  • copy and paste errors
    • there were several times where two different function bodies had exactly the same contents
    • there was a nested for loop that used the same index variable as the loop in the outer scope
    • two adjacent if statements tested for the exact same condition
  • bad use of comma in for loop
    • A for loop’s controlling expression (the middle one) cannot be a list of comma-separated expressions—use the logical AND operator to concatenate multiple expressions
  • confusing bitwise AND and logical AND
  • confusing bitwise OR and logical OR
  • types mistakes
    • comparing a CHAR8 to a really large value that CHAR8 is not capable of containing
    • checking to see if a unsigned variable is less than zero

The good news is that all of Nikolaj’s bugs have been fixed in the latest version of the Quark BSP package.  You can download the latest version of the Quark BSP package here:

Also, you can find Nikolaj’s original article here, in Russian.

Post a Comment

Be sure to select an account profile (e.g. Google, OpenID, etc.) before typing your comment!