Index: dll/win32/setupapi/parser.c
===================================================================
--- dll/win32/setupapi/parser.c	(revision 66794)
+++ dll/win32/setupapi/parser.c	(working copy)
@@ -186,7 +186,7 @@
 {
     struct section *section;
     struct line *line;
-    int i;
+    unsigned int i;
 
     if (section_index < 0 || section_index >= file->nb_sections) return NULL;
     section = file->sections[section_index];
@@ -402,7 +402,7 @@
 {
     const WCHAR *start, *subst, *p;
     unsigned int len, total = 0;
-    int inside = 0;
+    BOOL inside = FALSE;
 
     if (!buffer) size = MAX_STRING_LEN + 1;
     for (p = start = text; *p; p++)
@@ -503,7 +503,7 @@
 
 
 /* check if the pointer points to an end of file */
-static inline int is_eof( const struct parser *parser, const WCHAR *ptr )
+static inline BOOL is_eof( const struct parser *parser, const WCHAR *ptr )
 {
     return (ptr >= parser->end || *ptr == CONTROL_Z);
 }
@@ -510,7 +510,7 @@
 
 
 /* check if the pointer points to an end of line */
-static inline int is_eol( const struct parser *parser, const WCHAR *ptr )
+static inline BOOL is_eol( const struct parser *parser, const WCHAR *ptr )
 {
     return (ptr >= parser->end || *ptr == CONTROL_Z || *ptr == '\n');
 }
@@ -560,7 +560,7 @@
 
 
 /* add a field containing the current token to the current line */
-static struct field *add_field_from_token( struct parser *parser, int is_key )
+static struct field *add_field_from_token( struct parser *parser, BOOL is_key )
 {
     struct field *field;
     WCHAR *text;
@@ -680,7 +680,7 @@
 
          case '=':
             push_token( parser, token_end );
-            if (!add_field_from_token( parser, 1 )) return NULL;
+            if (!add_field_from_token( parser, TRUE )) return NULL;
             parser->start = p + 1;
             push_state( parser, VALUE_NAME );
             set_state( parser, LEADING_SPACES );
@@ -687,7 +687,7 @@
             return p + 1;
         case ';':
             push_token( parser, token_end );
-            if (!add_field_from_token( parser, 0 )) return NULL;
+            if (!add_field_from_token( parser, FALSE )) return NULL;
             push_state( parser, LINE_START );
             set_state( parser, COMMENT );
             return p + 1;
@@ -732,13 +732,13 @@
         {
         case ';':
             push_token( parser, token_end );
-            if (!add_field_from_token( parser, 0 )) return NULL;
+            if (!add_field_from_token( parser, FALSE )) return NULL;
             push_state( parser, LINE_START );
             set_state( parser, COMMENT );
             return p + 1;
         case ',':
             push_token( parser, token_end );
-            if (!add_field_from_token( parser, 0 )) return NULL;
+            if (!add_field_from_token( parser, FALSE )) return NULL;
             parser->start = p + 1;
             push_state( parser, VALUE_NAME );
             set_state( parser, LEADING_SPACES );
@@ -768,7 +768,7 @@
         }
     }
     push_token( parser, token_end );
-    if (!add_field_from_token( parser, 0 )) return NULL;
+    if (!add_field_from_token( parser, FALSE )) return NULL;
     set_state( parser, LINE_START );
     return p;
 }
@@ -887,7 +887,18 @@
     return p;
 }
 
+static void free_inf_file( struct inf_file *file )
+{
+    unsigned int i;
 
+    for (i = 0; i < file->nb_sections; i++) HeapFree( GetProcessHeap(), 0, file->sections[i] );
+    HeapFree( GetProcessHeap(), 0, file->filename );
+    HeapFree( GetProcessHeap(), 0, file->sections );
+    HeapFree( GetProcessHeap(), 0, file->fields );
+    HeapFree( GetProcessHeap(), 0, file->strings );
+    HeapFree( GetProcessHeap(), 0, file );
+}
+
 /* parse a complete buffer */
 static DWORD parse_buffer( struct inf_file *file, const WCHAR *buffer, const WCHAR *end,
                            UINT *error_line )
@@ -1012,7 +1023,7 @@
     }
     else
     {
-        WCHAR *new_buff = (WCHAR *)buffer;
+        WCHAR *new_buff = buffer;
         /* UCS-16 files should start with the Unicode BOM; we should skip it */
         if (*new_buff == 0xfeff)
             new_buff++;
@@ -1041,7 +1052,7 @@
     UnmapViewOfFile( buffer );
     if (err)
     {
-        HeapFree( GetProcessHeap(), 0, file );
+        if (file) free_inf_file( file );
         SetLastError( err );
         file = NULL;
     }
@@ -1251,7 +1262,7 @@
 
     if (handle != INVALID_HANDLE_VALUE)
     {
-        file = parse_file( handle, error, style );
+        file = parse_file( handle, error, style);
         CloseHandle( handle );
     }
     if (!file)
@@ -1293,7 +1304,7 @@
     }
 
     SetLastError( 0 );
-    return (HINF)file;
+    return file;
 }
 
 
@@ -1366,16 +1377,10 @@
 void WINAPI SetupCloseInfFile( HINF hinf )
 {
     struct inf_file *file = hinf;
-    unsigned int i;
 
     if (!hinf || (hinf == INVALID_HANDLE_VALUE)) return;
 
-    for (i = 0; i < file->nb_sections; i++) HeapFree( GetProcessHeap(), 0, file->sections[i] );
-    HeapFree( GetProcessHeap(), 0, file->filename );
-    HeapFree( GetProcessHeap(), 0, file->sections );
-    HeapFree( GetProcessHeap(), 0, file->fields );
-    HeapFree( GetProcessHeap(), 0, file->strings );
-    HeapFree( GetProcessHeap(), 0, file );
+    free_inf_file( file );
 }
 
 
