[PATCH weston] Make sure config.h is included before any system headers

Andrew Wedgbury andrew.wedgbury at realvnc.com
Mon Apr 7 04:40:35 PDT 2014


There was an issue recently in screen-share.c where config.h was not 
being included, resulting in the wrong definition for off_t being used on 
32 bit systems. I checked and I don't think this problem is happening 
elsewhere, but to help avoid this sort of problem in the future, I went 
through and made sure that config.h is included first whenever system 
headers are included.

The config.h header should be included before any system headers, failing
to do this can result in the wrong type sizes being defined on certain
systems, e.g. off_t from sys/types.h

Signed-off-by: Andrew Wedgbury <andrew.wedgbury at realvnc.com>
---
  clients/calibrator.c              | 2 ++
  clients/clickdot.c                | 2 ++
  clients/cliptest.c                | 2 ++
  clients/dnd.c                     | 2 ++
  clients/eventdemo.c               | 2 ++
  clients/flower.c                  | 2 ++
  clients/fullscreen.c              | 2 ++
  clients/image.c                   | 2 ++
  clients/keyboard.c                | 2 ++
  clients/nested-client.c           | 2 ++
  clients/nested.c                  | 2 ++
  clients/resizor.c                 | 2 ++
  clients/scaler.c                  | 2 ++
  clients/simple-egl.c              | 2 ++
  clients/smoke.c                   | 2 ++
  clients/subsurfaces.c             | 2 ++
  clients/transformed.c             | 2 ++
  clients/window.h                  | 2 ++
  clients/wscreensaver.h            | 2 ++
  shared/os-compatibility.h         | 4 ++--
  src/vaapi-recorder.c              | 2 ++
  tests/bad-buffer-test.c           | 2 ++
  tests/buffer-count-test.c         | 2 ++
  tests/button-test.c               | 2 ++
  tests/config-parser-test.c        | 2 ++
  tests/matrix-test.c               | 2 ++
  tests/setbacklight.c              | 2 ++
  tests/subsurface-test.c           | 2 ++
  tests/surface-global-test.c       | 2 ++
  tests/text-test.c                 | 2 ++
  tests/vertex-clip-test.c          | 3 +++
  tests/weston-test-client-helper.h | 2 ++
  tests/weston-test-runner.h        | 2 ++
  33 files changed, 67 insertions(+), 2 deletions(-)

diff --git a/clients/calibrator.c b/clients/calibrator.c
index 783cdec..1eb117f 100644
--- a/clients/calibrator.c
+++ b/clients/calibrator.c
@@ -20,6 +20,8 @@
   * OF THIS SOFTWARE.
   */

+#include "config.h"
+
  #include <stdint.h>
  #include <stdio.h>
  #include <stdlib.h>
diff --git a/clients/clickdot.c b/clients/clickdot.c
index c300fa5..e09cb14 100644
--- a/clients/clickdot.c
+++ b/clients/clickdot.c
@@ -22,6 +22,8 @@
   * OF THIS SOFTWARE.
   */

+#include "config.h"
+
  #include <stdint.h>
  #include <stdio.h>
  #include <stdlib.h>
diff --git a/clients/cliptest.c b/clients/cliptest.c
index 89c3ca7..3cee343 100644
--- a/clients/cliptest.c
+++ b/clients/cliptest.c
@@ -30,6 +30,8 @@
   *	surface transform disable key: r
   */

+#include "config.h"
+
  #include <stdint.h>
  #include <stdio.h>
  #include <stdlib.h>
diff --git a/clients/dnd.c b/clients/dnd.c
index 00739c3..a463d6f 100644
--- a/clients/dnd.c
+++ b/clients/dnd.c
@@ -20,6 +20,8 @@
   * OF THIS SOFTWARE.
   */

+#include "config.h"
+
  #include <assert.h>
  #include <stdint.h>
  #include <stdio.h>
diff --git a/clients/eventdemo.c b/clients/eventdemo.c
index 029b1d8..5ec6829 100644
--- a/clients/eventdemo.c
+++ b/clients/eventdemo.c
@@ -30,6 +30,8 @@
   * \author Tim Wiederhake
   */

+#include "config.h"
+
  #include <stdio.h>
  #include <stdlib.h>

diff --git a/clients/flower.c b/clients/flower.c
index 389f8be..8769445 100644
--- a/clients/flower.c
+++ b/clients/flower.c
@@ -20,6 +20,8 @@
   * OF THIS SOFTWARE.
   */

+#include "config.h"
+
  #include <stdint.h>
  #include <stdio.h>
  #include <stdlib.h>
diff --git a/clients/fullscreen.c b/clients/fullscreen.c
index 7dc4374..fa8028a 100644
--- a/clients/fullscreen.c
+++ b/clients/fullscreen.c
@@ -21,6 +21,8 @@
   * OF THIS SOFTWARE.
   */

+#include "config.h"
+
  #include <stdint.h>
  #include <stdio.h>
  #include <stdlib.h>
diff --git a/clients/image.c b/clients/image.c
index 3a52c22..054979d 100644
--- a/clients/image.c
+++ b/clients/image.c
@@ -21,6 +21,8 @@
   * OF THIS SOFTWARE.
   */

+#include "config.h"
+
  #include <stdint.h>
  #include <stdio.h>
  #include <stdlib.h>
diff --git a/clients/keyboard.c b/clients/keyboard.c
index 6876cde..11fe21d 100644
--- a/clients/keyboard.c
+++ b/clients/keyboard.c
@@ -21,6 +21,8 @@
   * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
   */

+#include "config.h"
+
  #include <stdio.h>
  #include <stdlib.h>
  #include <string.h>
diff --git a/clients/nested-client.c b/clients/nested-client.c
index 1161a99..7f237e6 100644
--- a/clients/nested-client.c
+++ b/clients/nested-client.c
@@ -20,6 +20,8 @@
   * OF THIS SOFTWARE.
   */

+#include "config.h"
+
  #include <stdio.h>
  #include <stdlib.h>
  #include <string.h>
diff --git a/clients/nested.c b/clients/nested.c
index 3bdb961..44389e4 100644
--- a/clients/nested.c
+++ b/clients/nested.c
@@ -20,6 +20,8 @@
   * OF THIS SOFTWARE.
   */

+#include "config.h"
+
  #include <stdint.h>
  #include <stdio.h>
  #include <stdlib.h>
diff --git a/clients/resizor.c b/clients/resizor.c
index b5ea55f..029042f 100644
--- a/clients/resizor.c
+++ b/clients/resizor.c
@@ -20,6 +20,8 @@
   * OF THIS SOFTWARE.
   */

+#include "config.h"
+
  #include <stdint.h>
  #include <stdio.h>
  #include <stdlib.h>
diff --git a/clients/scaler.c b/clients/scaler.c
index 2a43fcf..f94e714 100644
--- a/clients/scaler.c
+++ b/clients/scaler.c
@@ -21,6 +21,8 @@
   * OF THIS SOFTWARE.
   */

+#include "config.h"
+
  #include <stdio.h>
  #include <string.h>
  #include <assert.h>
diff --git a/clients/simple-egl.c b/clients/simple-egl.c
index 410e3ab..0d4673b 100644
--- a/clients/simple-egl.c
+++ b/clients/simple-egl.c
@@ -20,6 +20,8 @@
   * OF THIS SOFTWARE.
   */

+#include "config.h"
+
  #include <stdio.h>
  #include <stdlib.h>
  #include <string.h>
diff --git a/clients/smoke.c b/clients/smoke.c
index dd5f4bd..5d976af 100644
--- a/clients/smoke.c
+++ b/clients/smoke.c
@@ -20,6 +20,8 @@
   * OF THIS SOFTWARE.
   */

+#include "config.h"
+
  #include <stdint.h>
  #include <stdio.h>
  #include <stdlib.h>
diff --git a/clients/subsurfaces.c b/clients/subsurfaces.c
index 45cc44b..66a10f2 100644
--- a/clients/subsurfaces.c
+++ b/clients/subsurfaces.c
@@ -22,6 +22,8 @@
   * OF THIS SOFTWARE.
   */

+#include "config.h"
+
  #include <stdint.h>
  #include <stdio.h>
  #include <stdlib.h>
diff --git a/clients/transformed.c b/clients/transformed.c
index dd246a0..4b1cb05 100644
--- a/clients/transformed.c
+++ b/clients/transformed.c
@@ -21,6 +21,8 @@
   * OF THIS SOFTWARE.
   */

+#include "config.h"
+
  #include <stdint.h>
  #include <stdio.h>
  #include <stdlib.h>
diff --git a/clients/window.h b/clients/window.h
index ae3af40..4e4ccc1 100644
--- a/clients/window.h
+++ b/clients/window.h
@@ -23,6 +23,8 @@
  #ifndef _WINDOW_H_
  #define _WINDOW_H_

+#include "config.h"
+
  #include <xkbcommon/xkbcommon.h>
  #include <wayland-client.h>
  #include <cairo.h>
diff --git a/clients/wscreensaver.h b/clients/wscreensaver.h
index e2749d9..f85b94c 100644
--- a/clients/wscreensaver.h
+++ b/clients/wscreensaver.h
@@ -23,6 +23,8 @@
  #ifndef WSCREENSAVER_H
  #define WSCREENSAVER_H

+#include "config.h"
+
  #define MESA_EGL_NO_X11_HEADERS
  #include <EGL/egl.h>

diff --git a/shared/os-compatibility.h b/shared/os-compatibility.h
index 10dbb7d..172bb7e 100644
--- a/shared/os-compatibility.h
+++ b/shared/os-compatibility.h
@@ -23,10 +23,10 @@
  #ifndef OS_COMPATIBILITY_H
  #define OS_COMPATIBILITY_H

-#include <sys/types.h>
-
  #include "config.h"

+#include <sys/types.h>
+
  #ifdef HAVE_EXECINFO_H
  #include <execinfo.h>
  #else
diff --git a/src/vaapi-recorder.c b/src/vaapi-recorder.c
index 4131407..0095a42 100644
--- a/src/vaapi-recorder.c
+++ b/src/vaapi-recorder.c
@@ -43,6 +43,8 @@
   * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
   */

+#include "config.h"
+
  #include <stdlib.h>
  #include <stdint.h>
  #include <string.h>
diff --git a/tests/bad-buffer-test.c b/tests/bad-buffer-test.c
index 4f5f810..6eae313 100644
--- a/tests/bad-buffer-test.c
+++ b/tests/bad-buffer-test.c
@@ -21,6 +21,8 @@
   * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
   */

+#include "config.h"
+
  #include <unistd.h>
  #include <sys/types.h>

diff --git a/tests/buffer-count-test.c b/tests/buffer-count-test.c
index dfc4673..8b1dd5d 100644
--- a/tests/buffer-count-test.c
+++ b/tests/buffer-count-test.c
@@ -20,6 +20,8 @@
   * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
   */

+#include "config.h"
+
  #include <string.h>

  #include "weston-test-client-helper.h"
diff --git a/tests/button-test.c b/tests/button-test.c
index dc02fd4..d5ad813 100644
--- a/tests/button-test.c
+++ b/tests/button-test.c
@@ -20,6 +20,8 @@
   * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
   */

+#include "config.h"
+
  #include <linux/input.h>
  #include "weston-test-client-helper.h"

diff --git a/tests/config-parser-test.c b/tests/config-parser-test.c
index 4b8fc7e..4b255b7 100644
--- a/tests/config-parser-test.c
+++ b/tests/config-parser-test.c
@@ -20,6 +20,8 @@
   * OF THIS SOFTWARE.
   */

+#include "config.h"
+
  #include <stdlib.h>
  #include <stdint.h>
  #include <string.h>
diff --git a/tests/matrix-test.c b/tests/matrix-test.c
index 5b0513f..7b414c9 100644
--- a/tests/matrix-test.c
+++ b/tests/matrix-test.c
@@ -20,6 +20,8 @@
   * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
   */

+#include "config.h"
+
  #include <stdio.h>
  #include <stdlib.h>
  #include <math.h>
diff --git a/tests/setbacklight.c b/tests/setbacklight.c
index 92bd4bf..c8eba43 100644
--- a/tests/setbacklight.c
+++ b/tests/setbacklight.c
@@ -28,6 +28,8 @@
   * program.
   */

+#include "config.h"
+
  #include <stdio.h>
  #include <stdlib.h>
  #include <unistd.h>
diff --git a/tests/subsurface-test.c b/tests/subsurface-test.c
index 1c2641b..0670e7f 100644
--- a/tests/subsurface-test.c
+++ b/tests/subsurface-test.c
@@ -20,6 +20,8 @@
   * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
   */

+#include "config.h"
+
  #include <string.h>

  #include "weston-test-client-helper.h"
diff --git a/tests/surface-global-test.c b/tests/surface-global-test.c
index b496635..edc5d9f 100644
--- a/tests/surface-global-test.c
+++ b/tests/surface-global-test.c
@@ -20,6 +20,8 @@
   * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
   */

+#include "config.h"
+
  #include <assert.h>

  #include "../src/compositor.h"
diff --git a/tests/text-test.c b/tests/text-test.c
index 1f10b1b..c838a5d 100644
--- a/tests/text-test.c
+++ b/tests/text-test.c
@@ -20,6 +20,8 @@
   * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
   */

+#include "config.h"
+
  #include <string.h>
  #include <stdio.h>
  #include <linux/input.h>
diff --git a/tests/vertex-clip-test.c b/tests/vertex-clip-test.c
index 6d44aa2..1a09437 100644
--- a/tests/vertex-clip-test.c
+++ b/tests/vertex-clip-test.c
@@ -19,6 +19,9 @@
   * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
   * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
   */
+
+#include "config.h"
+
  #include <assert.h>
  #include <stdio.h>
  #include <stdlib.h>
diff --git a/tests/weston-test-client-helper.h b/tests/weston-test-client-helper.h
index 6670ab3..4bfc3fa 100644
--- a/tests/weston-test-client-helper.h
+++ b/tests/weston-test-client-helper.h
@@ -23,6 +23,8 @@
  #ifndef _WESTON_TEST_CLIENT_HELPER_H_
  #define _WESTON_TEST_CLIENT_HELPER_H_

+#include "config.h"
+
  #include <assert.h>
  #include "weston-test-runner.h"
  #include "wayland-test-client-protocol.h"
diff --git a/tests/weston-test-runner.h b/tests/weston-test-runner.h
index 457cf31..e1db040 100644
--- a/tests/weston-test-runner.h
+++ b/tests/weston-test-runner.h
@@ -24,6 +24,8 @@
  #ifndef _WESTON_TEST_RUNNER_H_
  #define _WESTON_TEST_RUNNER_H_

+#include "config.h"
+
  #include <stdlib.h>

  #ifdef NDEBUG
-- 
1.9.1


More information about the wayland-devel mailing list