]> git.sur5r.net Git - i3/i3/commitdiff
Merge pull request #1816 from tcreech/tcreech-for-illumos
authorMichael Stapelberg <stapelberg@users.noreply.github.com>
Tue, 4 Aug 2015 07:10:06 +0000 (00:10 -0700)
committerMichael Stapelberg <stapelberg@users.noreply.github.com>
Tue, 4 Aug 2015 07:10:06 +0000 (00:10 -0700)
Changes for compiling i3 on Illumos

1  2 
i3-config-wizard/main.c
include/libi3.h
src/ipc.c
src/util.c

diff --combined i3-config-wizard/main.c
index bd9aa28a4146d2404bbf3d174361b524c11c97ae,9b8a486d5183404cfe26d93e0d01ac63547af37c..bd12cd815af594191df3e2f7c60f958d2a4bfbfc
@@@ -392,7 -392,7 +392,7 @@@ static char *rewrite_binding(const cha
                      }
                  }
                  if (walk != beginning) {
 -                    char *str = scalloc(walk - beginning + 1);
 +                    char *str = scalloc(walk - beginning + 1, 1);
                      /* We copy manually to handle escaping of characters. */
                      int inpos, outpos;
                      for (inpos = 0, outpos = 0;
@@@ -768,7 -768,7 +768,7 @@@ int main(int argc, char *argv[]) 
          switch (o) {
              case 's':
                  FREE(socket_path);
 -                socket_path = strdup(optarg);
 +                socket_path = sstrdup(optarg);
                  break;
              case 'v':
                  printf("i3-config-wizard " I3_VERSION "\n");
      struct stat stbuf;
      sasprintf(&config_dir, "%s/i3", xdg_config_home);
      if (stat(config_dir, &stbuf) != 0)
-         if (!mkdirp(config_dir))
+         if (mkdirp(config_dir, DEFAULT_DIR_MODE) != 0)
              err(EXIT_FAILURE, "mkdirp(%s) failed", config_dir);
      free(config_dir);
      free(xdg_config_home);
diff --combined include/libi3.h
index 102ad533d57acc01c8ca424102bd8420f126f593,971e565e3f1209a3073a3cfc0092aed567298c5b..9e7ef133fb4ca3ce49d253fa2956adcec57186b7
@@@ -21,6 -21,8 +21,8 @@@
  #include <pango/pango.h>
  #endif
  
+ #define DEFAULT_DIR_MODE (S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)
  /**
   * Opaque data structure for storing strings.
   *
@@@ -111,7 -113,7 +113,7 @@@ void *smalloc(size_t size)
   * there is no more memory available)
   *
   */
 -void *scalloc(size_t size);
 +void *scalloc(size_t num, size_t size);
  
  /**
   * Safe-wrapper around realloc which exits if realloc returns NULL (meaning
@@@ -471,8 -473,10 +473,10 @@@ char *resolve_tilde(const char *path)
   */
  char *get_config_path(const char *override_configpath, bool use_system_paths);
  
+ #if !defined(__sun)
  /**
   * Emulates mkdir -p (creates any missing folders)
   *
   */
- bool mkdirp(const char *path);
+ int mkdirp(const char *path, mode_t mode);
+ #endif
diff --combined src/ipc.c
index a4bc227896f4b5de41c1e33c27235de7118c041d,4af78ab2762a47cd22c75d58e919cf4eec16238e..021bdd7bf1b2f57e5c989a807866d43232c1d43c
+++ b/src/ipc.c
@@@ -84,7 -84,7 +84,7 @@@ void ipc_shutdown(void) 
  IPC_HANDLER(command) {
      /* To get a properly terminated buffer, we copy
       * message_size bytes out of the buffer */
 -    char *command = scalloc(message_size + 1);
 +    char *command = scalloc(message_size + 1, 1);
      strncpy(command, (const char *)message, message_size);
      LOG("IPC: received: *%s*\n", command);
      yajl_gen gen = yajl_gen_alloc(NULL);
@@@ -855,7 -855,7 +855,7 @@@ IPC_HANDLER(get_bar_config) 
  
      /* To get a properly terminated buffer, we copy
       * message_size bytes out of the buffer */
 -    char *bar_id = scalloc(message_size + 1);
 +    char *bar_id = scalloc(message_size + 1, 1);
      strncpy(bar_id, (const char *)message, message_size);
      LOG("IPC: looking for config for bar ID \"%s\"\n", bar_id);
      Barconfig *current, *config = NULL;
@@@ -900,10 -900,10 +900,10 @@@ static int add_subscription(void *extra
      int event = client->num_events;
  
      client->num_events++;
 -    client->events = realloc(client->events, client->num_events * sizeof(char *));
 +    client->events = srealloc(client->events, client->num_events * sizeof(char *));
      /* We copy the string because it is not null-terminated and strndup()
       * is missing on some BSD systems */
 -    client->events[event] = scalloc(len + 1);
 +    client->events[event] = scalloc(len + 1, 1);
      memcpy(client->events[event], s, len);
  
      DLOG("client is now subscribed to:\n");
@@@ -1060,13 -1060,13 +1060,13 @@@ void ipc_new_client(EV_P_ struct ev_io 
  
      set_nonblock(client);
  
 -    struct ev_io *package = scalloc(sizeof(struct ev_io));
 +    struct ev_io *package = scalloc(1, sizeof(struct ev_io));
      ev_io_init(package, ipc_receive_message, client, EV_READ);
      ev_io_start(EV_A_ package);
  
      DLOG("IPC: new client connected on fd %d\n", w->fd);
  
 -    ipc_client *new = scalloc(sizeof(ipc_client));
 +    ipc_client *new = scalloc(1, sizeof(ipc_client));
      new->fd = client;
  
      TAILQ_INSERT_TAIL(&all_clients, new, clients);
@@@ -1087,7 -1087,7 +1087,7 @@@ int ipc_create_socket(const char *filen
      char *copy = sstrdup(resolved);
      const char *dir = dirname(copy);
      if (!path_exists(dir))
-         mkdirp(dir);
+         mkdirp(dir, DEFAULT_DIR_MODE);
      free(copy);
  
      /* Unlink the unix domain socket before */
diff --combined src/util.c
index 5a95e67cd401c6a0207e850734323c6e5b63387a,5568fc714c619ba70663e29a377f8e3557b4e8fd..0edd471a2c247b7448ee54392dcecc86a08ae4c1
@@@ -122,7 -122,7 +122,7 @@@ void exec_i3_utility(char *name, char *
      /* if the script is not in path, maybe the user installed to a strange
       * location and runs the i3 binary with an absolute path. We use
       * argv[0]’s dirname */
 -    char *pathbuf = strdup(start_argv[0]);
 +    char *pathbuf = sstrdup(start_argv[0]);
      char *dir = dirname(pathbuf);
      sasprintf(&migratepath, "%s/%s", dir, name);
      argv[0] = migratepath;
@@@ -222,7 -222,7 +222,7 @@@ char *store_restart_layout(void) 
      char *filenamecopy = sstrdup(filename);
      char *base = dirname(filenamecopy);
      DLOG("Creating \"%s\" for storing the restart layout\n", base);
-     if (!mkdirp(base))
+     if (mkdirp(base, DEFAULT_DIR_MODE) != 0)
          ELOG("Could not create \"%s\" for storing the restart layout, layout will be lost.\n", base);
      free(filenamecopy);
  
@@@ -276,7 -276,7 +276,7 @@@ void i3_restart(bool forget_layout) 
          int num_args;
          for (num_args = 0; start_argv[num_args] != NULL; num_args++)
              ;
 -        char **new_argv = scalloc((num_args + 3) * sizeof(char *));
 +        char **new_argv = scalloc(num_args + 3, sizeof(char *));
  
          /* copy the arguments, but skip the ones we'll replace */
          int write_index = 0;