commit-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[mig] 01/01: Fix warnings


From: Samuel Thibault
Subject: [mig] 01/01: Fix warnings
Date: Sun, 18 Feb 2018 18:25:33 +0000

This is an automated email from the git hooks/post-receive script.

sthibault pushed a commit to branch master
in repository mig.

commit 6c3792352a69dd0d46761fc823f5f68170d2c11c
Author: Samuel Thibault <address@hidden>
Date:   Sun Feb 18 18:25:10 2018 +0000

    Fix warnings
    
      * patches/memcpy: Port upstream fix for type-punning warnings.
      * patches/const: Port upstream fix for const warnings.
      * control: Break gnumach-dev which does not provide const types.
---
 debian/changelog      |  8 ++++++
 debian/control        |  1 +
 debian/patches/const  | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++
 debian/patches/memcpy | 33 +++++++++++++++++++++++++
 debian/patches/series |  2 ++
 5 files changed, 111 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index 433d462..1c8f68f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+mig (1.8-3) UNRELEASED; urgency=medium
+
+  * patches/memcpy: Port upstream fix for type-punning warnings.
+  * patches/const: Port upstream fix for const warnings.
+  * control: Break gnumach-dev which does not provide const types.
+
+ -- Samuel Thibault <address@hidden>  Sun, 18 Feb 2018 18:23:58 +0000
+
 mig (1.8-2) unstable; urgency=medium
 
   * Use canonical anonscm vcs URL.
diff --git a/debian/control b/debian/control
index d40c2dd..2e08cc8 100644
--- a/debian/control
+++ b/debian/control
@@ -14,6 +14,7 @@ Package: mig
 Architecture: any-i386
 Multi-Arch: foreign
 Depends: ${misc:Depends}, ${shlibs:Depends}
+Breaks: gnumach-dev (<< 2:1.8+git20171101-2~)
 Description: GNU Mach Interface Generator
  This is the GNU distribution of the MIG, which is needed to compile
  the GNU C library, the GNU Hurd and GNU Mach.
diff --git a/debian/patches/const b/debian/patches/const
new file mode 100644
index 0000000..55f99f3
--- /dev/null
+++ b/debian/patches/const
@@ -0,0 +1,67 @@
+commit 74172cdd9a4b056d27ce2524e0aa0f3fcb2b0770
+Author: Samuel Thibault <address@hidden>
+Date:   Sun Jan 28 16:35:16 2018 +0100
+
+    Fix RPC build warnings
+    
+    Users of RPCs want to be able to pass pointers to const data, so add
+    const qualifiers to RPCs as appropriate.
+    
+    * utils.c (UserVarConst, UserVarQualifier): New functions.
+    (WriteUserVarDecl): Use UserVarQualifier to qualify function parameter.
+    (WriteFieldDeclPrim): Use UserVarConst to qualify pointer to user
+    variable.
+
+diff --git a/utils.c b/utils.c
+index 265a123..4ddadc5 100644
+--- a/utils.c
++++ b/utils.c
+@@ -144,12 +144,36 @@ WriteNameDecl(FILE *file, const argument_t *arg)
+     fprintf(file, "%s", arg->argVarName);
+ }
+ 
++/* Returns whether parameter should be qualified with const because we will 
only
++   send the pointed data, not receive it. */
++static boolean_t
++UserVarConst(const argument_t *arg)
++{
++    return (arg->argKind & (akbSend|akbReturn)) == akbSend
++          && !arg->argType->itStruct;
++}
++
++static const char *
++UserVarQualifier(const argument_t *arg)
++{
++    if (!UserVarConst(arg))
++      return "";
++
++    if (arg->argType->itIndefinite)
++        /* This is a pointer type, so we have to use the const_foo type to
++         make const qualify the data, not the pointer.  */
++      return "const_";
++    else
++      return "const ";
++}
++
+ void
+ WriteUserVarDecl(FILE *file, const argument_t *arg)
+ {
++    const char *qualif = UserVarQualifier(arg);
+     const char *ref = arg->argByReferenceUser ? "*" : "";
+ 
+-    fprintf(file, "\t%s %s%s", arg->argType->itUserType, ref, 
arg->argVarName);
++    fprintf(file, "\t%s%s %s%s", qualif, arg->argType->itUserType, ref, 
arg->argVarName);
+ }
+ 
+ void
+@@ -244,7 +268,9 @@ WriteFieldDeclPrim(FILE *file, const argument_t *arg,
+                       (*tfunc)(btype),
+                       arg->argMsgField,
+                       it->itNumber/btype->itNumber);
+-      fprintf(file, "\t\t\t%s *%s%s;\n",
++      fprintf(file, "\t\t\t%s%s *%s%s;\n",
++                      tfunc == FetchUserType && UserVarConst(arg)
++                              ? "const " : "",
+                       (*tfunc)(btype),
+                       arg->argMsgField,
+                       OOLPostfix);
diff --git a/debian/patches/memcpy b/debian/patches/memcpy
new file mode 100644
index 0000000..b98e3b5
--- /dev/null
+++ b/debian/patches/memcpy
@@ -0,0 +1,33 @@
+commit 789a7e7299a580f295d1abd327bb4acf063fd9f0
+Author: Samuel Thibault <address@hidden>
+Date:   Sun Jan 28 01:26:49 2018 +0100
+
+    Fix compilation warnings
+    
+    Nowadays' compilers are able to recognize memcpy and replace it
+    appropriately without having to tell them so through a structure
+    assignment. That also avoids warnings about type puning.
+    
+    * utils.c (WriteCopyType): Emit memcpy call instead of type-puned
+    assignement.
+
+diff --git a/utils.c b/utils.c
+index d6a2b72..265a123 100644
+--- a/utils.c
++++ b/utils.c
+@@ -408,12 +408,11 @@ WriteCopyType(FILE *file, const ipc_type_t *it, const 
char *left,
+     }
+     else
+     {
+-      fprintf(file, "\t{ typedef struct { char data[%d]; } *sp; * (sp) ",
+-              it->itTypeSize);
++      fprintf(file, "\tmemcpy(");
+       do_skip_vfprintf(file, left, right);
+-      fprintf(file, " = * (sp) ");
++      fprintf(file, ", ");
+       do_skip_vfprintf(file, right, right);
+-      fprintf(file, "; }\n");
++      fprintf(file, ", %d);\n", it->itTypeSize);
+     }
+ }
+ 
diff --git a/debian/patches/series b/debian/patches/series
index 118f48f..ed15d11 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +1,3 @@
 warning
+memcpy
+const

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-hurd/mig.git



reply via email to

[Prev in Thread] Current Thread [Next in Thread]