- Fix various warnings in inflib (thanks to Ged for help with what appears to be...
[reactos.git] / reactos / lib / inflib / infcore.c
index 18ad68d..8bdffb7 100644 (file)
@@ -48,7 +48,7 @@ struct parser
   PINFCACHESECTION cur_section;   /* pointer to the section being parsed*/
   PINFCACHELINE    line;          /* current line */
   unsigned int     line_pos;      /* current line position in file */
-  unsigned int     error;         /* error code */
+  INFSTATUS        error;         /* error code */
   unsigned int     token_len;     /* current token len */
   TCHAR token[MAX_FIELD_LEN+1];   /* current token */
 };
@@ -181,7 +181,8 @@ InfpAddSection(PINFCACHE Cache,
     }
 
   /* Allocate and initialize the new section */
-  Size = sizeof(INFCACHESECTION) + (_tcslen (Name) * sizeof(TCHAR));
+  Size = (ULONG)FIELD_OFFSET(INFCACHESECTION,
+                             Name[_tcslen (Name) + 1]);
   Section = (PINFCACHESECTION)MALLOC (Size);
   if (Section == NULL)
     {
@@ -285,7 +286,8 @@ InfpAddFieldToLine(PINFCACHELINE Line,
   PINFCACHEFIELD Field;
   ULONG Size;
 
-  Size = sizeof(INFCACHEFIELD) + (_tcslen(Data) * sizeof(TCHAR));
+  Size = (ULONG)FIELD_OFFSET(INFCACHEFIELD,
+                             Data[_tcslen(Data) + 1]);
   Field = (PINFCACHEFIELD)MALLOC(Size);
   if (Field == NULL)
     {
@@ -380,7 +382,7 @@ __inline static int is_eol( struct parser *parser, const CHAR *ptr )
 /* push data from current token start up to pos into the current token */
 static int push_token( struct parser *parser, const CHAR *pos )
 {
-  unsigned int len = pos - parser->start;
+  UINT len = (UINT)(pos - parser->start);
   const CHAR *src = parser->start;
   TCHAR *dst = parser->token + parser->token_len;
 
@@ -389,7 +391,17 @@ static int push_token( struct parser *parser, const CHAR *pos )
 
   parser->token_len += len;
   for ( ; len > 0; len--, dst++, src++)
-    *dst = *src ? (TCHAR)*src : L' ';
+  {
+    if (*src)
+    {
+      *dst = *src;
+    }
+    else
+    {
+      *dst = _T(' ');
+    }
+  }
+
   *dst = 0;
   parser->start = pos;