Changeset 1021 for trunk/layout.c


Ignore:
Timestamp:
05/31/10 00:24:40 (2 years ago)
Author:
hailfinger
Message:

Remove unneeded #include statements completely.

unistd.h was only used to get a definition of NULL in all files. Add our
own NULL #define and remove unistd.h from flash.h
stdio.h has no place in flash.h, it should be included only in files
which really need it.
Add #include statements in individual .c files where needed.

Replace a few printf with msg_* to eliminate the need for stdio.h.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@…>
Acked-by: Uwe Hermann <uwe@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/layout.c

    r996 r1021  
    1919 */ 
    2020 
     21#include <stdio.h> 
    2122#include <stdlib.h> 
    2223#include <string.h> 
     
    7475        if ((*walk) == 0 || ((*walk) & 0x3ff) != 0 || (*walk) > size || 
    7576            mb_part_offset > size || mb_vendor_offset > size) { 
    76                 printf("Flash image seems to be a legacy BIOS. Disabling checks.\n"); 
     77                msg_pinfo("Flash image seems to be a legacy BIOS. Disabling checks.\n"); 
    7778                return 0; 
    7879        } 
     
    8283        if (!isprint((unsigned char)*mb_part) || 
    8384            !isprint((unsigned char)*mb_vendor)) { 
    84                 printf("Flash image seems to have garbage in the ID location." 
     85                msg_pinfo("Flash image seems to have garbage in the ID location." 
    8586                       " Disabling checks.\n"); 
    8687                return 0; 
    8788        } 
    8889 
    89         printf_debug("coreboot last image size " 
     90        msg_pdbg("coreboot last image size " 
    9091                     "(not ROM size) is %d bytes.\n", *walk); 
    9192 
    9293        mainboard_part = strdup(mb_part); 
    9394        mainboard_vendor = strdup(mb_vendor); 
    94         printf_debug("Manufacturer: %s\n", mainboard_vendor); 
    95         printf_debug("Mainboard ID: %s\n", mainboard_part); 
     95        msg_pdbg("Manufacturer: %s\n", mainboard_vendor); 
     96        msg_pdbg("Mainboard ID: %s\n", mainboard_part); 
    9697 
    9798        /* 
     
    100101         */ 
    101102        if (!lb_vendor || !lb_part) { 
    102                 printf("Note: If the following flash access fails, " 
     103                msg_pinfo("Note: If the following flash access fails, " 
    103104                       "try -m <vendor>:<mainboard>.\n"); 
    104105                return 0; 
     
    110111        if (!strcasecmp(mainboard_vendor, lb_vendor) && 
    111112            !strcasecmp(mainboard_part, lb_part)) { 
    112                 printf_debug("This firmware image matches this mainboard.\n"); 
     113                msg_pdbg("This firmware image matches this mainboard.\n"); 
    113114        } else { 
    114115                if (force_boardmismatch) { 
    115                         printf("WARNING: This firmware image does not " 
     116                        msg_pinfo("WARNING: This firmware image does not " 
    116117                               "seem to fit to this machine - forcing it.\n"); 
    117118                } else { 
    118                         printf("ERROR: Your firmware image (%s:%s) does not " 
     119                        msg_pinfo("ERROR: Your firmware image (%s:%s) does not " 
    119120                               "appear to\n       be correct for the detected " 
    120121                               "mainboard (%s:%s)\n\nOverride with -p internal:" 
     
    142143 
    143144        if (!romlayout) { 
    144                 fprintf(stderr, "ERROR: Could not open ROM layout (%s).\n", 
     145                msg_gerr("ERROR: Could not open ROM layout (%s).\n", 
    145146                        name); 
    146147                return -1; 
     
    160161                tstr2 = strtok(NULL, ":"); 
    161162                if (!tstr1 || !tstr2) { 
    162                         fprintf(stderr, "Error parsing layout file.\n"); 
     163                        msg_gerr("Error parsing layout file.\n"); 
    163164                        fclose(romlayout); 
    164165                        return 1; 
     
    171172 
    172173        for (i = 0; i < romimages; i++) { 
    173                 printf_debug("romlayout %08x - %08x named %s\n", 
     174                msg_gdbg("romlayout %08x - %08x named %s\n", 
    174175                             rom_entries[i].start, 
    175176                             rom_entries[i].end, rom_entries[i].name); 
     
    188189                return -1; 
    189190 
    190         printf("Looking for \"%s\"... ", name); 
     191        msg_ginfo("Looking for \"%s\"... ", name); 
    191192 
    192193        for (i = 0; i < romimages; i++) { 
    193194                if (!strcmp(rom_entries[i].name, name)) { 
    194195                        rom_entries[i].included = 1; 
    195                         printf("found.\n"); 
     196                        msg_ginfo("found.\n"); 
    196197                        return i; 
    197198                } 
    198199        } 
    199         printf("not found.\n"); // Not found. Error. 
     200        msg_ginfo("not found.\n");      // Not found. Error. 
    200201 
    201202        return -1; 
Note: See TracChangeset for help on using the changeset viewer.