Changeset 489

Show
Ignore:
Timestamp:
08/11/07 00:30:46 (1 year ago)
Author:
ctate
Message:

* Guard types.h against multiple inclusion

* Widespread cleanup of compile warnings, with the goal of making it more likely that any occurrence of those warnings indicates a bona fide bug:

- Because MSVC is slightly stupid sometimes, change

if (!(var = some_func()))

to

if ((var = some_func()) == 0)

to suppress the warning about a possible unintended assignment in a conditional

- Initialize a number of variables that trigger a "var possibly used uninitialized" warning in MSVC

- Remove unused local variables

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/init1.c

    r470 r489  
    927927 
    928928                /* Store the name */ 
    929                 if (!(v_ptr->name = add_name(head, s))
     929                if ((v_ptr->name = add_name(head, s)) == 0
    930930                        return (PARSE_ERROR_OUT_OF_MEMORY); 
    931931        } 
     
    10261026 
    10271027                /* Store the name */ 
    1028                 if (!(f_ptr->name = add_name(head, s))
     1028                if ((f_ptr->name = add_name(head, s)) == 0
    10291029                        return (PARSE_ERROR_OUT_OF_MEMORY); 
    10301030 
     
    12091209 
    12101210                /* Store the name */ 
    1211                 if (!(k_ptr->name = add_name(head, s))
     1211                if ((k_ptr->name = add_name(head, s)) == 0
    12121212                        return (PARSE_ERROR_OUT_OF_MEMORY); 
    12131213 
     
    15401540 
    15411541                /* Store the name */ 
    1542                 if (!(a_ptr->name = add_name(head, s))
     1542                if ((a_ptr->name = add_name(head, s)) == 0
    15431543                        return (PARSE_ERROR_OUT_OF_MEMORY); 
    15441544 
     
    17731773 
    17741774                /* Store the name */ 
    1775                 if (!(e_ptr->name = add_name(head, s))
     1775                if ((e_ptr->name = add_name(head, s)) == 0
    17761776                        return (PARSE_ERROR_OUT_OF_MEMORY); 
    17771777 
     
    20012001 
    20022002                /* Store the name */ 
    2003                 if (!(r_ptr->name = add_name(head, s))
     2003                if ((r_ptr->name = add_name(head, s)) == 0
    20042004                        return (PARSE_ERROR_OUT_OF_MEMORY); 
    20052005 
     
    23152315 
    23162316                /* Store the name */ 
    2317                 if (!(pr_ptr->name = add_name(head, s))
     2317                if ((pr_ptr->name = add_name(head, s)) == 0
    23182318                        return (PARSE_ERROR_OUT_OF_MEMORY); 
    23192319        } 
     
    25642564 
    25652565                /* Store the name */ 
    2566                 if (!(pc_ptr->name = add_name(head, s))
     2566                if ((pc_ptr->name = add_name(head, s)) == 0
    25672567                        return (PARSE_ERROR_OUT_OF_MEMORY); 
    25682568 
     
    29482948 
    29492949                /* Store the name */ 
    2950                 if (!(ot_ptr->owner_name = add_name(head, t))
     2950                if ((ot_ptr->owner_name = add_name(head, t)) == 0
    29512951                        return (PARSE_ERROR_OUT_OF_MEMORY); 
    29522952        } 
     
    32093209 
    32103210                /* Store the name */ 
    3211                 if (!(s_ptr->name = add_name(head, s))
     3211                if ((s_ptr->name = add_name(head, s)) == 0
    32123212                        return (PARSE_ERROR_OUT_OF_MEMORY); 
    32133213        } 
  • trunk/src/monster2.c

    r450 r489  
    19781978        int px = p_ptr->px; 
    19791979 
    1980         int y, x
     1980        int y = 0, x = 0
    19811981        int     attempts_left = 10000; 
    19821982 
     
    21662166bool summon_specific(int y1, int x1, int lev, int type) 
    21672167{ 
    2168         int i, x, y, r_idx; 
     2168        int i, x = 0, y = 0, r_idx; 
    21692169 
    21702170 
  • trunk/src/randart.c

    r410 r489  
    11561156        s32b power; 
    11571157        int tries; 
    1158         s32b ap
     1158        s32b ap = 0
    11591159        bool curse_me = FALSE; 
    11601160        bool aggravate_me = FALSE; 
  • trunk/src/randname.c

    r175 r489  
    282282size_t randname_make(randname_type name_type, size_t min, size_t max, char *word_buf, size_t buflen) 
    283283{ 
    284         size_t lnum
     284        size_t lnum = 0
    285285        bool found_word = FALSE; 
    286286 
  • trunk/src/save.c

    r479 r489  
    10581058        if (save_player_aux(new_savefile)) 
    10591059        { 
    1060                 int error; 
    1061  
    10621060                safe_setuid_grab(); 
    10631061 
  • trunk/src/store.c

    r471 r489  
    26522652 
    26532653        menu_type menu; 
    2654         event_type evt
     2654        event_type evt = EVENT_EMPTY
    26552655        int cursor = 0; 
    26562656 
  • trunk/src/types.h

    r484 r489  
    3737 */ 
    3838 
     39#ifndef INCLUDED_TYPES_H 
     40#define INCLUDED_TYPES_H 
    3941 
    4042 
     
    11381140} grid_data; 
    11391141 
     1142 
     1143#endif /* !INCLUDED_TYPES_H */ 
  • trunk/src/ui.c

    r471 r489  
    116116event_type run_event_loop(event_target * target, bool forever, const event_type *start) 
    117117{ 
    118         event_type ke
     118        event_type ke = EVENT_EMPTY
    119119        bool handled = TRUE; 
    120120 
  • trunk/src/util.c

    r479 r489  
    306306                        { 
    307307                                size_t j; 
    308                                 while ((tmp = strchr(macro_modifier_chr, *str))
     308                                while ((tmp = strchr(macro_modifier_chr, *str)) != 0
    309309                                { 
    310310                                        j = tmp - macro_modifier_chr; 
  • trunk/src/win/readdib.c

    r253 r489  
    228228        } 
    229229 
    230         if (!(nNumColors = (WORD)lpbi->biClrUsed)
     230        if ((nNumColors = (WORD)lpbi->biClrUsed) == 0
    231231        { 
    232232                /* no color table for 24-bit, default size otherwise */