summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2015-05-09 11:19:33 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2015-05-09 11:19:33 -0700
commitaf90a105ec97c6d856d2e8a80e8822c3e192d1e9 (patch)
tree88e8a1428621f6dd10eb7c37370723d2e6a1b7e8
parent9ffefd5b3d38e9ed2b5ed59bc50e8a7da761fb77 (diff)
Replace remaining sprintf calls with snprintf
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--actions.c12
-rw-r--r--comm.c24
-rw-r--r--geometry.c30
-rw-r--r--handler.c5
-rw-r--r--setvalues.c7
-rw-r--r--svpopup.c2
-rw-r--r--utils.c12
-rw-r--r--wtree.c12
8 files changed, 52 insertions, 52 deletions
diff --git a/actions.c b/actions.c
index b5e1338..800839d 100644
--- a/actions.c
+++ b/actions.c
@@ -188,8 +188,7 @@ PopdownFileDialogAction(Widget w, XEvent *event,
Boolean val;
if (*num_params != 1) {
- sprintf(buf, res_labels[2],
- "PopdownFileDialog");
+ snprintf(buf, sizeof(buf), res_labels[2], "PopdownFileDialog");
SetMessage(global_screen_data.info_label, buf);
return;
@@ -202,8 +201,7 @@ PopdownFileDialogAction(Widget w, XEvent *event,
else if (streq(buf, "okay"))
val = TRUE;
else {
- sprintf(buf, res_labels[1],
- "PopdownFileDialog");
+ snprintf(buf, sizeof(buf), res_labels[1], "PopdownFileDialog");
SetMessage(global_screen_data.info_label, buf);
return;
@@ -284,8 +282,7 @@ CheckAndFindEntry(String action_name, String *params, Cardinal num_params,
int i;
if (num_params != 1) {
- sprintf(buf, res_labels[2],
- action_name);
+ snprintf(buf, sizeof(buf), res_labels[2], action_name);
SetMessage(global_screen_data.info_label, buf);
return(FALSE);
}
@@ -297,8 +294,7 @@ CheckAndFindEntry(String action_name, String *params, Cardinal num_params,
return(TRUE);
}
- sprintf(buf,res_labels[3],
- action_name);
+ snprintf(buf, sizeof(buf), res_labels[3], action_name);
for (i = 0; i < num_table; ) {
strcat(buf, table[i++].name);
diff --git a/comm.c b/comm.c
index b7aa0d8..fb949e3 100644
--- a/comm.c
+++ b/comm.c
@@ -90,8 +90,7 @@ ClientTimedOut(XtPointer data, XtIntervalId *id)
XtDisownSelection(w, global_client.atom,
XtLastTimestampProcessed(XtDisplay(w)));
- sprintf(msg, res_labels[4],
- "the Editres Protocol.");
+ snprintf(msg, sizeof(msg), res_labels[4], "the Editres Protocol.");
SetMessage(global_screen_data.info_label, msg);
}
@@ -226,13 +225,12 @@ SetCommand(Widget w, ResCommand command, char *msg)
XSync(dpy, FALSE);
XSetErrorHandler(global_old_error_handler);
if (global_error_code == NO_WINDOW) {
- char error_buf[BUFSIZ];
+ char error_buf[BUFSIZ] =
+ "The communication window with the"
+ " application is no longer available\n"
+ "Please select a new widget tree.";
global_error_code = NO_ERROR; /* Reset Error code. */
- sprintf(error_buf, "The communication window with%s%s.",
- " application is no longer available\n",
- "Please select a new widget tree");
-
global_client.window = None;
SetCommand(w, LocalSendWidgetTree, error_buf);
return;
@@ -280,7 +278,7 @@ TellUserAboutMessage(Widget label, ResCommand command)
break;
}
- sprintf(msg, res_labels[8], str);
+ snprintf(msg, sizeof(msg), res_labels[8], str);
SetMessage(label, msg);
}
@@ -420,7 +418,7 @@ GetClientValue(Widget w, XtPointer data, Atom *selection, Atom *type,
FreeEvent(event);
}
else {
- sprintf(msg, "Unable to unpack protocol request.");
+ snprintf(msg, sizeof(msg), "Unable to unpack protocol request.");
error_str = XtNewString(msg);
}
break;
@@ -438,7 +436,7 @@ GetClientValue(Widget w, XtPointer data, Atom *selection, Atom *type,
SetCommand(w, LocalSendWidgetTree, NULL);
break;
default:
- sprintf(msg, res_labels[11], (int) error_code);
+ snprintf(msg, sizeof(msg), res_labels[11], (int) error_code);
SetMessage(global_screen_data.info_label, msg);
break;
}
@@ -450,7 +448,7 @@ GetClientValue(Widget w, XtPointer data, Atom *selection, Atom *type,
return;
top = global_tree_info->top_node;
- sprintf(msg, res_labels[12], top->name, top->class);
+ snprintf(msg, sizeof(msg), res_labels[12], top->name, top->class);
SetMessage(global_screen_data.info_label, msg);
return;
}
@@ -893,8 +891,8 @@ DispatchEvent(Event *event)
default:
{
char msg[BUFSIZ];
- sprintf(msg, "Internal error: Unknown command %d.",
- global_client.command);
+ snprintf(msg, sizeof(msg), "Internal error: Unknown command %d.",
+ global_client.command);
error = XtNewString(msg);
}
break;
diff --git a/geometry.c b/geometry.c
index 8f3adea..0bc9445 100644
--- a/geometry.c
+++ b/geometry.c
@@ -63,7 +63,7 @@ _FindWidget(Widget w)
Window win;
int x, y; /* location of event in root coordinates. */
- sprintf(msg, res_labels[14]);
+ snprintf(msg, sizeof(msg), res_labels[14]);
SetMessage(global_screen_data.info_label, msg);
@@ -103,7 +103,7 @@ DisplayChild(Event *event)
find_event->widgets.num_widgets);
if (node == NULL) {
- sprintf(msg, res_labels[13]);
+ snprintf(msg, sizeof(msg), res_labels[13]);
SetMessage(global_screen_data.info_label, msg);
return;
}
@@ -112,7 +112,7 @@ DisplayChild(Event *event)
node = node->tree_info->top_node;
- sprintf(msg, res_labels[12], node->name, node->class);
+ snprintf(msg, sizeof(msg), res_labels[12], node->name, node->class);
SetMessage(global_screen_data.info_label, msg);
_FlashActiveWidgets(global_tree_info);
@@ -193,7 +193,8 @@ AddToFlashList(TreeInfo *tree_info, GetGeomInfo *geom_info, char **errors)
geom_info->widgets.ids, geom_info->widgets.num_widgets);
if (node == NULL) {
- sprintf(buf, "Editres Internal Error: Unable to FindNode.\n");
+ snprintf(buf, sizeof(buf),
+ "Editres Internal Error: Unable to FindNode.\n");
AddString(errors, buf);
return;
}
@@ -204,7 +205,7 @@ AddToFlashList(TreeInfo *tree_info, GetGeomInfo *geom_info, char **errors)
}
if (!geom_info->visable) {
- sprintf(buf, "%s(0x%lx) - This widget is not mapped\n",
+ snprintf(buf, sizeof(buf), "%s(0x%lx) - This widget is not mapped\n",
node->name, node->id);
AddString(errors, buf);
return;
@@ -240,11 +241,13 @@ _AddToFlashList(TreeInfo *tree_info, char **errors, WNode *node,
char buf[BUFSIZ];
if (node->window == EDITRES_IS_OBJECT)
- sprintf(buf, "%s(0x%lx) - This object's parent is unrealized\n",
- node->name, node->id);
+ snprintf(buf, sizeof(buf),
+ "%s(0x%lx) - This object's parent is unrealized\n",
+ node->name, node->id);
else
- sprintf(buf, "%s(0x%lx) - This widget is unrealized\n",
- node->name, node->id);
+ snprintf(buf, sizeof(buf),
+ "%s(0x%lx) - This widget is unrealized\n",
+ node->name, node->id);
AddString(errors, buf);
return;
@@ -261,8 +264,9 @@ _AddToFlashList(TreeInfo *tree_info, char **errors, WNode *node,
if (global_error_code == NO_WINDOW) {
char buf[BUFSIZ];
- sprintf(buf, "%s(0x%lx) - This widget's window no longer exists.\n",
- node->name, node->id);
+ snprintf(buf, sizeof(buf),
+ "%s(0x%lx) - This widget's window no longer exists.\n",
+ node->name, node->id);
AddString(errors, buf);
return;
}
@@ -270,8 +274,8 @@ _AddToFlashList(TreeInfo *tree_info, char **errors, WNode *node,
if (attrs.map_state != IsViewable) {
char buf[BUFSIZ];
- sprintf(buf, "%s(0x%lx) - This widget is not mapped.\n",
- node->name, node->id);
+ snprintf(buf, sizeof(buf), "%s(0x%lx) - This widget is not mapped.\n",
+ node->name, node->id);
AddString(errors, buf);
return;
}
diff --git a/handler.c b/handler.c
index 8235294..f209971 100644
--- a/handler.c
+++ b/handler.c
@@ -564,8 +564,9 @@ _AppendResourceString(Widget w, XtPointer res_box_ptr, XtPointer filename_ptr)
}
if ((fp = fopen(global_resources.save_resources_file, "a+")) == NULL) {
- sprintf(buf, "Unable to open this file for writing, would %s",
- "you like To try again?");
+ snprintf(buf, sizeof(buf), "%s",
+ "Unable to open this file for writing, would "
+ "you like To try again?");
_PopupFileDialog(global_toplevel ,buf,
global_resources.save_resources_file,
_AppendResourceString, res_box_ptr);
diff --git a/setvalues.c b/setvalues.c
index a28bcf9..09896d1 100644
--- a/setvalues.c
+++ b/setvalues.c
@@ -64,13 +64,14 @@ PrintSetValuesError(Event *event)
sv_event->info[i].widgets.num_widgets);
if (node == NULL) {
- sprintf(buf, "Editres Internal Error: Unable to FindNode.\n");
+ snprintf(buf, sizeof(buf),
+ "Editres Internal Error: Unable to FindNode.\n");
AddString(&errors, buf);
continue;
}
- sprintf(buf, "%s(0x%lx) - %s\n", node->name, node->id,
- sv_event->info[i].message);
+ snprintf(buf, sizeof(buf), "%s(0x%lx) - %s\n", node->name, node->id,
+ sv_event->info[i].message);
AddString(&errors, buf);
}
return(errors);
diff --git a/svpopup.c b/svpopup.c
index 8e3fe8f..b0a32c8 100644
--- a/svpopup.c
+++ b/svpopup.c
@@ -127,7 +127,7 @@ ModifySVEntry(Widget w, XEvent *event, String *params, Cardinal *num_params)
old = global_screen_data.res_text;
break;
default:
- sprintf(msg, res_labels[22]);
+ snprintf(msg, sizeof(msg), res_labels[22]);
SetMessage(global_screen_data.info_label, msg);
return;
}
diff --git a/utils.c b/utils.c
index 73d7534..a0f74d0 100644
--- a/utils.c
+++ b/utils.c
@@ -271,7 +271,7 @@ _DumpTreeToFile(Widget w, XtPointer tree_ptr, XtPointer filename)
if ( (fp = fopen((char *)filename, "w")) == NULL ) {
char buf[BUFSIZ];
- sprintf(buf, res_labels[24], (char *)filename);
+ snprintf(buf, sizeof(buf), res_labels[24], (char *)filename);
SetMessage(global_screen_data.info_label, buf);
return;
}
@@ -518,7 +518,7 @@ HandleGetResources(Event *event)
get_event->info[i].widgets.num_widgets);
if (node == NULL) {
- sprintf(buf, res_labels[16]);
+ snprintf(buf, sizeof(buf), res_labels[16]);
AddString(&errors, buf);
continue;
}
@@ -629,8 +629,8 @@ ParseResources(GetResourcesInfo *info, char **error)
default:
{
char buf[BUFSIZ];
- sprintf(buf, "Unknown resource type %d\n",
- info->res_info[i].res_type);
+ snprintf(buf, sizeof(buf), "Unknown resource type %d\n",
+ info->res_info[i].res_type);
AddString(error, buf);
}
break;
@@ -863,8 +863,8 @@ ProtocolFailure(ProtocolStream *stream)
default: old_version_string = "1.0";
}
- sprintf(buf, res_labels[36],
- CURRENT_PROTOCOL_VERSION_STRING, old_version_string);
+ snprintf(buf, sizeof(buf), res_labels[36],
+ CURRENT_PROTOCOL_VERSION_STRING, old_version_string);
return(XtNewString(buf));
}
diff --git a/wtree.c b/wtree.c
index 3a39f30..9c3a884 100644
--- a/wtree.c
+++ b/wtree.c
@@ -84,7 +84,7 @@ BuildVisualTree(Widget tree_parent, Event *event)
XtManageChild(global_tree_info->tree_widget);
- sprintf(msg, res_labels[11], top->name, top->class);
+ snprintf(msg, sizeof(msg), res_labels[11], top->name, top->class);
SetMessage(global_screen_data.info_label, msg);
}
@@ -107,8 +107,8 @@ AddTreeNode(Widget tree, WNode *top)
if (top->parent != NULL) {
if (top->parent->widget == NULL) {
- sprintf( msg, res_labels[28],
- top->name, top->parent->name, "not been created yet");
+ snprintf(msg, sizeof(msg), res_labels[28],
+ top->name, top->parent->name, "not been created yet");
SetMessage(global_screen_data.info_label, msg);
}
XtSetArg(args[num_args], XtNtreeParent, top->parent->widget);
@@ -120,7 +120,7 @@ AddTreeNode(Widget tree, WNode *top)
if (XSaveContext(XtDisplay(top->widget), (Window) top->widget,
NODE_INFO, (XPointer) top) != 0) {
- sprintf( msg, res_labels[29], top->name);
+ snprintf(msg, sizeof(msg), res_labels[29], top->name);
SetMessage(global_screen_data.info_label, msg);
}
@@ -411,7 +411,7 @@ _TreeRelabelNode(WNode *node, LabelTypes type, Boolean recurse)
XtSetArg(args[0], XtNlabel, node->name);
break;
case IDLabel:
- sprintf(buf, "id: 0x%lx", node->id);
+ snprintf(buf, sizeof(buf), "id: 0x%lx", node->id);
XtSetArg(args[0], XtNlabel, buf);
break;
case WindowLabel:
@@ -420,7 +420,7 @@ _TreeRelabelNode(WNode *node, LabelTypes type, Boolean recurse)
else if (node->window == EDITRES_IS_OBJECT)
strcpy(buf, "non windowed object");
else
- sprintf(buf, "win: 0x%lx", node->window);
+ snprintf(buf, sizeof(buf), "win: 0x%lx", node->window);
XtSetArg(args[0], XtNlabel, buf);
break;