Skip to content
This repository has been archived by the owner on Apr 18, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Ensure all *.[ch] files include config.h
Including config.h is necessary to get e.g. the _GNU_SOURCE define and
any other definitions that autoconf declares. Hence, config.h needs to
be included as the first header in each file.

This is done either via:
1. Including "common.h" (i3bar)
2. Including "libi3.h"
3. Including "all.h" (i3)
4. Including <config.h> directly

Also remove now-unused I3__FILE__, add copyright/license statement
where missing and switch include/all.h to #pragma once.
  • Loading branch information
stapelberg committed Oct 23, 2016
1 parent c2bd10c commit f354f53
Show file tree
Hide file tree
Showing 134 changed files with 230 additions and 149 deletions.
2 changes: 2 additions & 0 deletions i3-config-wizard/main.c
Expand Up @@ -8,6 +8,8 @@
* keysyms.
*
*/
#include <config.h>

#if defined(__FreeBSD__)
#include <sys/param.h>
#endif
Expand Down
2 changes: 2 additions & 0 deletions i3-dump-log/main.c
Expand Up @@ -7,6 +7,8 @@
* i3-dump-log/main.c: Dumps the i3 SHM log to stdout.
*
*/
#include <config.h>

#include <stdio.h>
#include <stdbool.h>
#include <sys/types.h>
Expand Down
2 changes: 2 additions & 0 deletions i3-input/i3-input.h
@@ -1,5 +1,7 @@
#pragma once

#include <config.h>

#include <err.h>

#define die(...) errx(EXIT_FAILURE, __VA_ARGS__);
Expand Down
4 changes: 2 additions & 2 deletions i3-input/main.c
Expand Up @@ -8,6 +8,8 @@
* to i3.
*
*/
#include "libi3.h"

#include <stdio.h>
#include <sys/types.h>
#include <stdlib.h>
Expand All @@ -31,8 +33,6 @@

#include "i3-input.h"

#include "libi3.h"

/* IPC format string. %s will be replaced with what the user entered, then
* the command will be sent to i3 */
static char *format;
Expand Down
3 changes: 2 additions & 1 deletion i3-msg/main.c
Expand Up @@ -14,6 +14,8 @@
* Additionally, it’s even useful sometimes :-).
*
*/
#include "libi3.h"

#include <stdio.h>
#include <stdbool.h>
#include <sys/types.h>
Expand All @@ -34,7 +36,6 @@
#include <xcb/xcb.h>
#include <xcb/xcb_aux.h>

#include "libi3.h"
#include <i3/ipc.h>

static char *socket_path;
Expand Down
2 changes: 2 additions & 0 deletions i3-nagbar/i3-nagbar.h
@@ -1,5 +1,7 @@
#pragma once

#include <config.h>

#include <err.h>

#define die(...) errx(EXIT_FAILURE, __VA_ARGS__);
Expand Down
3 changes: 2 additions & 1 deletion i3-nagbar/main.c
Expand Up @@ -8,6 +8,8 @@
* when the user has an error in their configuration file.
*
*/
#include "libi3.h"

#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
Expand All @@ -30,7 +32,6 @@
#include <xcb/randr.h>
#include <xcb/xcb_cursor.h>

#include "libi3.h"
#include "i3-nagbar.h"

/** This is the equivalent of XC_left_ptr. I’m not sure why xcb doesn’t have a
Expand Down
2 changes: 2 additions & 0 deletions i3bar/include/child.h
Expand Up @@ -9,6 +9,8 @@
*/
#pragma once

#include <config.h>

#include <stdbool.h>

#define STDIN_CHUNK_SIZE 1024
Expand Down
2 changes: 2 additions & 0 deletions i3bar/include/common.h
Expand Up @@ -7,6 +7,8 @@
*/
#pragma once

#include <config.h>

#include <stdbool.h>
#include <xcb/xcb.h>
#include <xcb/xproto.h>
Expand Down
2 changes: 2 additions & 0 deletions i3bar/include/configuration.h
Expand Up @@ -9,6 +9,8 @@
*/
#pragma once

#include <config.h>

#include "common.h"

typedef enum {
Expand Down
2 changes: 2 additions & 0 deletions i3bar/include/ipc.h
Expand Up @@ -9,6 +9,8 @@
*/
#pragma once

#include <config.h>

#include <stdint.h>

/*
Expand Down
2 changes: 2 additions & 0 deletions i3bar/include/mode.h
Expand Up @@ -9,6 +9,8 @@
*/
#pragma once

#include <config.h>

#include <xcb/xproto.h>

#include "common.h"
Expand Down
2 changes: 2 additions & 0 deletions i3bar/include/outputs.h
Expand Up @@ -9,6 +9,8 @@
*/
#pragma once

#include <config.h>

#include <xcb/xcb.h>
#include <cairo/cairo-xcb.h>

Expand Down
2 changes: 2 additions & 0 deletions i3bar/include/parse_json_header.h
Expand Up @@ -10,6 +10,8 @@
*/
#pragma once

#include <config.h>

#include <stdint.h>

/**
Expand Down
2 changes: 2 additions & 0 deletions i3bar/include/util.h
Expand Up @@ -7,6 +7,8 @@
*/
#pragma once

#include <config.h>

#include "queue.h"

/* Get the maximum/minimum of x and y */
Expand Down
4 changes: 2 additions & 2 deletions i3bar/include/workspaces.h
Expand Up @@ -9,10 +9,10 @@
*/
#pragma once

#include <xcb/xproto.h>

#include "common.h"

#include <xcb/xproto.h>

typedef struct i3_ws i3_ws;

TAILQ_HEAD(ws_head, i3_ws);
Expand Down
2 changes: 2 additions & 0 deletions i3bar/include/xcb.h
Expand Up @@ -9,6 +9,8 @@
*/
#pragma once

#include <config.h>

#include <stdint.h>
//#include "outputs.h"

Expand Down
4 changes: 2 additions & 2 deletions i3bar/src/child.c
Expand Up @@ -7,6 +7,8 @@
* child.c: Getting input for the statusline
*
*/
#include "common.h"

#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
Expand All @@ -25,8 +27,6 @@
#include <yajl/yajl_gen.h>
#include <paths.h>

#include "common.h"

/* Global variables for child_*() */
i3bar_child child;

Expand Down
4 changes: 2 additions & 2 deletions i3bar/src/config.c
Expand Up @@ -7,6 +7,8 @@
* config.c: Parses the configuration (received from i3).
*
*/
#include "common.h"

#include <string.h>
#include <stdlib.h>
#include <stdio.h>
Expand All @@ -17,8 +19,6 @@

#include <X11/Xlib.h>

#include "common.h"

static char *cur_key;
static bool parsing_bindings;
static bool parsing_tray_outputs;
Expand Down
4 changes: 2 additions & 2 deletions i3bar/src/ipc.c
Expand Up @@ -7,6 +7,8 @@
* ipc.c: Communicating with i3
*
*/
#include "common.h"

#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
Expand All @@ -21,8 +23,6 @@
#include <sanitizer/lsan_interface.h>
#endif

#include "common.h"

ev_io *i3_connection;

const char *sock_path;
Expand Down
4 changes: 2 additions & 2 deletions i3bar/src/main.c
Expand Up @@ -5,6 +5,8 @@
* © 2010 Axel Wagner and contributors (see also: LICENSE)
*
*/
#include "common.h"

#include <stdio.h>
#include <i3/ipc.h>
#include <string.h>
Expand All @@ -15,8 +17,6 @@
#include <getopt.h>
#include <glob.h>

#include "common.h"

/*
* Having verboselog(), errorlog() and debuglog() is necessary when using libi3.
*
Expand Down
4 changes: 2 additions & 2 deletions i3bar/src/mode.c
Expand Up @@ -7,15 +7,15 @@
* mode.c: Handle mode event and show current binding mode in the bar
*
*/
#include "common.h"

#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <yajl/yajl_parse.h>
#include <yajl/yajl_version.h>

#include "common.h"

/* A datatype to pass through the callbacks to save the state */
struct mode_json_params {
char *json;
Expand Down
4 changes: 2 additions & 2 deletions i3bar/src/outputs.c
Expand Up @@ -7,6 +7,8 @@
* outputs.c: Maintaining the outputs list
*
*/
#include "common.h"

#include <string.h>
#include <stdlib.h>
#include <stdio.h>
Expand All @@ -15,8 +17,6 @@
#include <yajl/yajl_parse.h>
#include <yajl/yajl_version.h>

#include "common.h"

/* A datatype to pass through the callbacks to save the state */
struct outputs_json_params {
struct outputs_head *outputs;
Expand Down
4 changes: 2 additions & 2 deletions i3bar/src/parse_json_header.c
Expand Up @@ -8,6 +8,8 @@
* protocol version and features.
*
*/
#include "common.h"

#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
Expand All @@ -25,8 +27,6 @@
#include <yajl/yajl_parse.h>
#include <yajl/yajl_version.h>

#include "common.h"

static enum {
KEY_VERSION,
KEY_STOP_SIGNAL,
Expand Down
4 changes: 2 additions & 2 deletions i3bar/src/workspaces.c
Expand Up @@ -7,15 +7,15 @@
* workspaces.c: Maintaining the workspace lists
*
*/
#include "common.h"

#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <yajl/yajl_parse.h>
#include <yajl/yajl_version.h>

#include "common.h"

/* A datatype to pass through the callbacks to save the state */
struct workspaces_json_params {
struct ws_head *workspaces;
Expand Down
3 changes: 2 additions & 1 deletion i3bar/src/xcb.c
Expand Up @@ -7,6 +7,8 @@
* xcb.c: Communicating with X
*
*/
#include "common.h"

#include <xcb/xcb.h>
#include <xcb/xkb.h>
#include <xcb/xproto.h>
Expand All @@ -32,7 +34,6 @@
#include <sanitizer/lsan_interface.h>
#endif

#include "common.h"
#include "libi3.h"

/** This is the equivalent of XC_left_ptr. I’m not sure why xcb doesn’t have a
Expand Down
7 changes: 3 additions & 4 deletions include/all.h
Expand Up @@ -10,8 +10,9 @@
* compile-time.
*
*/
#ifndef I3_ALL_H
#define I3_ALL_H
#pragma once

#include <config.h>

#include <assert.h>
#include <stdbool.h>
Expand Down Expand Up @@ -81,5 +82,3 @@
#include "display_version.h"
#include "restore_layout.h"
#include "main.h"

#endif
2 changes: 2 additions & 0 deletions include/assignments.h
Expand Up @@ -9,6 +9,8 @@
*/
#pragma once

#include <config.h>

/**
* Checks the list of assignments for the given window and runs all matching
* ones (unless they have already been run for this specific window).
Expand Down
2 changes: 2 additions & 0 deletions include/bindings.h
Expand Up @@ -9,6 +9,8 @@
*/
#pragma once

#include <config.h>

extern pid_t command_error_nagbar_pid;

/**
Expand Down
2 changes: 2 additions & 0 deletions include/click.h
Expand Up @@ -9,6 +9,8 @@
*/
#pragma once

#include <config.h>

/**
* The button press X callback. This function determines whether the floating
* modifier is pressed and where the user clicked (decoration, border, inside
Expand Down
2 changes: 2 additions & 0 deletions include/cmdparse.h
Expand Up @@ -9,4 +9,6 @@
*/
#pragma once

#include <config.h>

char *parse_cmd(const char *new);

0 comments on commit f354f53

Please sign in to comment.