X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/83316bf4044b5fca98f19daae8f16a646b7e83e9..578098f346bf9e1f23ca86ed764fc00b035b427f:/src/xsmfns.c
diff --git a/src/xsmfns.c b/src/xsmfns.c
index f3879dbcec..8067899f93 100644
--- a/src/xsmfns.c
+++ b/src/xsmfns.c
@@ -1,7 +1,7 @@
/* Session management module for systems which understand the X Session
management protocol.
-Copyright (C) 2002-2011 Free Software Foundation, Inc.
+Copyright (C) 2002-2012 Free Software Foundation, Inc.
This file is part of GNU Emacs.
@@ -29,7 +29,6 @@ along with GNU Emacs. If not, see . */
#include
#include
#include
-#include
#include "lisp.h"
#include "systime.h"
@@ -41,8 +40,8 @@ along with GNU Emacs. If not, see . */
#include "process.h"
#include "keyboard.h"
-#ifndef HAVE_GTK3
-#define gdk_x11_set_sm_client_id(w) gdk_set_sm_client_id (w)
+#if defined USE_GTK && !defined HAVE_GTK3
+#define gdk_x11_set_sm_client_id(w) gdk_set_sm_client_id (w)
#endif
/* This is the event used when SAVE_SESSION_EVENT occurs. */
@@ -97,7 +96,7 @@ ice_connection_closed (void)
open to a session manager, just return. */
static void
-x_session_check_input (int fd, void *data, int for_read)
+x_session_check_input (int fd, void *data)
{
int ret;
@@ -190,7 +189,7 @@ smc_save_yourself_CB (SmcConn smcConn,
props[props_idx]->type = xstrdup (SmARRAY8);
props[props_idx]->num_vals = 1;
props[props_idx]->vals = &values[val_idx++];
- props[props_idx]->vals[0].length = strlen (SSDATA (Vinvocation_name));
+ props[props_idx]->vals[0].length = SBYTES (Vinvocation_name);
props[props_idx]->vals[0].value = SDATA (Vinvocation_name);
++props_idx;
@@ -200,7 +199,7 @@ smc_save_yourself_CB (SmcConn smcConn,
props[props_idx]->type = xstrdup (SmARRAY8);
props[props_idx]->num_vals = 1;
props[props_idx]->vals = &values[val_idx++];
- props[props_idx]->vals[0].length = strlen (SSDATA (Vuser_login_name));
+ props[props_idx]->vals[0].length = SBYTES (Vuser_login_name);
props[props_idx]->vals[0].value = SDATA (Vuser_login_name);
++props_idx;
@@ -223,9 +222,11 @@ smc_save_yourself_CB (SmcConn smcConn,
props[props_idx]->name = xstrdup (SmRestartCommand);
props[props_idx]->type = xstrdup (SmLISTofARRAY8);
/* /path/to/emacs, --smid=xxx --no-splash --chdir=dir ... */
+ if (INT_MAX - 3 < initial_argc)
+ memory_full (SIZE_MAX);
i = 3 + initial_argc;
props[props_idx]->num_vals = i;
- vp = (SmPropValue *) xmalloc (i * sizeof(*vp));
+ vp = xnmalloc (i, sizeof *vp);
props[props_idx]->vals = vp;
props[props_idx]->vals[vp_idx].length = strlen (emacs_program);
props[props_idx]->vals[vp_idx++].value = emacs_program;
@@ -250,7 +251,7 @@ smc_save_yourself_CB (SmcConn smcConn,
props[props_idx]->vals[vp_idx++].value = chdir_opt;
}
- for (i = 1; i < initial_argc; ++i)
+ for (i = 1; i < initial_argc; ++i)
{
props[props_idx]->vals[vp_idx].length = strlen (initial_argv[i]);
props[props_idx]->vals[vp_idx++].value = initial_argv[i];
@@ -365,11 +366,10 @@ ice_conn_watch_CB (IceConn iceConn, IcePointer clientData,
#ifndef USE_GTK
static void
-create_client_leader_window (struct x_display_info *dpyinfo, char *client_id)
+create_client_leader_window (struct x_display_info *dpyinfo, char *client_ID)
{
Window w;
XClassHint class_hints;
- Atom sm_id;
w = XCreateSimpleWindow (dpyinfo->display,
dpyinfo->root_window,
@@ -383,7 +383,7 @@ create_client_leader_window (struct x_display_info *dpyinfo, char *client_id)
XChangeProperty (dpyinfo->display, w, dpyinfo->Xatom_SM_CLIENT_ID,
XA_STRING, 8, PropModeReplace,
- (unsigned char *)client_id, strlen (client_id));
+ (unsigned char *) client_ID, strlen (client_ID));
dpyinfo->client_leader_window = w;
}
@@ -399,7 +399,7 @@ x_session_initialize (struct x_display_info *dpyinfo)
char errorstring[SM_ERRORSTRING_LEN];
char* previous_id = NULL;
SmcCallbacks callbacks;
- int name_len = 0;
+ ptrdiff_t name_len = 0;
ice_fd = -1;
doing_interact = False;
@@ -411,8 +411,8 @@ x_session_initialize (struct x_display_info *dpyinfo)
/* Construct the path to the Emacs program. */
if (! EQ (Vinvocation_directory, Qnil))
- name_len += strlen (SSDATA (Vinvocation_directory));
- name_len += strlen (SSDATA (Vinvocation_name));
+ name_len += SBYTES (Vinvocation_directory);
+ name_len += SBYTES (Vinvocation_name);
/* This malloc will not be freed, but it is only done once, and hopefully
not very large */
@@ -458,10 +458,10 @@ x_session_initialize (struct x_display_info *dpyinfo)
if (smc_conn != 0)
{
- Vx_session_id = make_string (client_id, strlen (client_id));
+ Vx_session_id = build_string (client_id);
#ifdef USE_GTK
- /* GTK creats a leader window by itself, but we need to tell
+ /* GTK creates a leader window by itself, but we need to tell
it about our client_id. */
gdk_x11_set_sm_client_id (client_id);
#else