aboutsummaryrefslogtreecommitdiff
path: root/user.c
diff options
context:
space:
mode:
authorJustus Winter <4winter@informatik.uni-hamburg.de>2015-02-15 13:29:30 +0100
committerJustus Winter <4winter@informatik.uni-hamburg.de>2015-02-15 14:33:33 +0100
commit44753cf5a30b9324d2c4ac9021843674bde5cc3c (patch)
tree743687464c6e13941fdf2cb4691843c6864fe2db /user.c
parentf573a84faeb902f74b5f4b6fc1a67e7579012a9e (diff)
downloadmig-44753cf5a30b9324d2c4ac9021843674bde5cc3c.tar.gz
mig-44753cf5a30b9324d2c4ac9021843674bde5cc3c.tar.bz2
mig-44753cf5a30b9324d2c4ac9021843674bde5cc3c.zip
Do not generate code dereferencing type-punned pointers
For variable-length arrays, up to 2048 bytes are transmitted inline. If the array is larger, the data is transmitted out-of-line, and a pointer to a vm_allocated region is stored at the beginning of the array. Previously, the generated code casted the field. Use a union instead. This fixes the gcc warning `dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]'. * global.c (OOLPostfix): New variable. * global.h (OOLPostfix): New declaration. * server.c (WriteServerCallArg): Avoid cast. (WriteDestroyArg): Likewise. (WritePackArgValue): Likewise. (WritePackArg): Likewise. * user.c (WriteExtractArgValue): Likewise. * utils.c (WriteFieldDeclPrim): Generate a union with an additional pointer field for variable-length arrays.
Diffstat (limited to 'user.c')
-rw-r--r--user.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/user.c b/user.c
index 5451a03..1f3ba3d 100644
--- a/user.c
+++ b/user.c
@@ -447,9 +447,9 @@ WritePackArgValue(FILE *file, const argument_t *arg)
arg->argLongForm ? ".msgtl_header" : "",
arg->argDealloc->argByReferenceUser ? "*" : "",
arg->argDealloc->argVarName);
- fprintf(file, "\t\t*((%s **)InP->%s) = %s%s;\n",
- FetchUserType(btype),
+ fprintf(file, "\t\tInP->%s%s = %s%s;\n",
arg->argMsgField,
+ OOLPostfix,
ref, arg->argVarName);
if (!arg->argRoutine->rtSimpleFixedRequest)
fprintf(file, "\t\tmsgh_simple = FALSE;\n");
@@ -951,9 +951,10 @@ WriteExtractArgValue(FILE *file, const argument_t *arg)
fprintf(file, "\tif (!OutP->%s%s.msgt_inline)\n",
arg->argTTName,
arg->argLongForm ? ".msgtl_header" : "");
- fprintf(file, "\t %s%s = *((%s **)OutP->%s);\n",
+ fprintf(file, "\t %s%s = OutP->%s%s;\n",
ref, arg->argVarName,
- FetchUserType(btype), arg->argMsgField);
+ arg->argMsgField,
+ OOLPostfix);
fprintf(file, "\telse if (OutP->%s", count->argMsgField);
if (btype->itNumber > 1)
fprintf(file, " / %d", btype->itNumber);