project-navigation
Personal tools

Author Topic: mismatch type in UI_PushDropDownWindow_f/Com_ParseValue  (Read 1889 times)

denis

  • Guest
mismatch type in UI_PushDropDownWindow_f/Com_ParseValue
« on: August 20, 2010, 11:48:00 pm »
revision 31675
In proc "static void UI_PushDropDownWindow_f (void)" (file: src/client/ui/ui_windows.c)
pointPosition in define as a byte

On line 304, function Com_ParseValue is call with &pointPosition as argument.
   result = Com_ParseValue(&pointPosition, Cmd_Argv(2), V_ALIGN, 0, sizeof(pointPosition), &writtenBytes);

Looking into function Com_ParseValue (file src/common/scripts.c line 472).
int Com_ParseValue (void *base, const char *token, valueTypes_t type, int ofs, size_t size, size_t *writtenBytes)

   byte *b;

   b = (byte *) base + ofs;
/* in this case b (type byte*) is an pointer on pointPosition (byte) --> fine */

/* line 721 */
   switch (type) {
   case V_ALIGN:
      for (num = 0; num < ALIGN_LAST; num++)
         if (!strcmp(token, align_names[num]))
            break;
      if (num == ALIGN_LAST)
         *(align_t *)b = 0;
      else
         *(align_t *)b = num;
/* b is type (byte *) which point on only 1 byte,
align_t is an enum define on 4 bytes
align_t * is a pointer on an enum define on 8 bytes
--> too much byte are changed, this make crash  */





denis

  • Guest
Fix according what is waiting + fix in vt_sizes
« Reply #1 on: August 21, 2010, 12:45:23 am »
Code: [Select]
Index: src/common/scripts.c
===================================================================
--- src/common/scripts.c (revision 31675)
+++ src/common/scripts.c (working copy)
@@ -376,10 +376,10 @@
  0, /* V_STRING */
  0, /* V_TRANSLATION_STRING */
  0, /* V_LONGSTRING */
- sizeof(byte), /* V_ALIGN */
- sizeof(byte), /* V_BLEND */
- sizeof(byte), /* V_STYLE */
- sizeof(byte), /* V_FADE */
+ sizeof(align_t), /* V_ALIGN */
+ sizeof(blend_t), /* V_BLEND */
+ sizeof(style_t), /* V_STYLE */
+ sizeof(fade_t), /* V_FADE */
  sizeof(int), /* V_SHAPE_SMALL */
  0, /* V_SHAPE_BIG */
  sizeof(byte), /* V_DMGTYPE */
Index: src/client/ui/ui_windows.c
===================================================================
--- src/client/ui/ui_windows.c (revision 31675)
+++ src/client/ui/ui_windows.c (working copy)
@@ -286,7 +286,7 @@
  vec2_t source;
  vec2_t destination;
  uiNode_t *node;
- byte pointPosition;
+ align_t pointPosition;
  size_t writtenBytes;
  int result;
 
Index: src/client/ui/node/ui_node_abstractnode.c
===================================================================
--- src/client/ui/node/ui_node_abstractnode.c (revision 31675)
+++ src/client/ui/node/ui_node_abstractnode.c (working copy)
@@ -68,7 +68,7 @@
  * @param [in] pointDirection
  * @note For example we can request the right-bottom corner with ALIGN_LR (low, right)
  */
-void UI_NodeGetPoint (const uiNode_t* node, vec2_t pos, byte pointDirection)
+void UI_NodeGetPoint (const uiNode_t* node, vec2_t pos, align_t pointDirection)
 {
  switch (pointDirection % 3) {
  case 0: /* left */
Index: src/client/ui/node/ui_node_abstractnode.h
===================================================================
--- src/client/ui/node/ui_node_abstractnode.h (revision 31675)
+++ src/client/ui/node/ui_node_abstractnode.h (working copy)
@@ -49,7 +49,7 @@
 void UI_GetNodeAbsPos(const struct uiNode_s* node, vec2_t pos);
 void UI_NodeAbsoluteToRelativePos(const struct uiNode_s* node, int *x, int *y);
 void UI_NodeRelativeToAbsolutePoint(const uiNode_t* node, vec2_t pos);
-void UI_NodeGetPoint(const uiNode_t* node, vec2_t pos, byte pointDirection);
+void UI_NodeGetPoint(const uiNode_t* node, vec2_t pos, align_t pointDirection);
 
 /* navigation */
 struct uiNode_s *UI_GetNode(const struct uiNode_s* const node, const char *name);
« Last Edit: August 21, 2010, 08:26:12 am by Mattn »

denis

  • Guest
Re: mismatch type in UI_PushDropDownWindow_f/Com_ParseValue
« Reply #2 on: August 21, 2010, 01:15:57 am »
may solve: http://ufoai.ninex.info/forum/index.php?topic=5272.0
I forgot to check if bug was reported.

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Re: mismatch type in UI_PushDropDownWindow_f/Com_ParseValue
« Reply #3 on: August 21, 2010, 08:36:48 am »
thanks - applied this to trunk - someone here with a powerpc who can try this on a big endian and different memory alignment architecture?