Change Epplet_dialog_ok() to printf() style
.. avoiding some format-truncation warnings.
This commit is contained in:
parent
03408c7d36
commit
49aafdaf62
49
api/epplet.c
49
api/epplet.c
|
@ -988,12 +988,8 @@ Epplet_cleanup(void)
|
|||
Esnprintf(s, sizeof(s), "%s/.lock_%i", conf_dir, epplet_instance);
|
||||
if (unlink(s) < 0)
|
||||
{
|
||||
char err[255];
|
||||
|
||||
Esnprintf(err, sizeof(err),
|
||||
"Unable to remove lock file %s -- %s.\n", s,
|
||||
strerror(errno));
|
||||
Epplet_dialog_ok(err);
|
||||
Epplet_dialog_ok("Unable to remove lock file %s -- %s.\n",
|
||||
s, strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5427,20 +5423,23 @@ Epplet_show_about(const char *name __UNUSED__)
|
|||
}
|
||||
|
||||
void
|
||||
Epplet_dialog_ok(const char *text)
|
||||
Epplet_dialog_ok(const char *fmt, ...)
|
||||
{
|
||||
char *s;
|
||||
va_list args;
|
||||
char buf[1000], s[1024];
|
||||
|
||||
va_start(args, fmt);
|
||||
Evsnprintf(buf, sizeof(buf), fmt, args);
|
||||
va_end(args);
|
||||
|
||||
if (!dd)
|
||||
{
|
||||
printf("*** %s\n", text);
|
||||
printf("*** %s\n", buf);
|
||||
return;
|
||||
}
|
||||
|
||||
s = malloc(strlen(text) + 32);
|
||||
sprintf(s, "dialog_ok %s", text);
|
||||
Esnprintf(s, sizeof(s), "dialog_ok %s", buf);
|
||||
ECommsSend(s);
|
||||
free(s);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -5475,12 +5474,9 @@ Epplet_find_instance(const char *name)
|
|||
{
|
||||
if (mkdir(s, S_IRWXU) < 0)
|
||||
{
|
||||
char buf[255];
|
||||
|
||||
Esnprintf(buf, sizeof(buf),
|
||||
"Unable to create epplet config directory %s -- %s.\n",
|
||||
s, strerror(errno));
|
||||
Epplet_dialog_ok(buf);
|
||||
Epplet_dialog_ok
|
||||
("Unable to create epplet config directory %s -- %s.\n",
|
||||
s, strerror(errno));
|
||||
epplet_instance = 1;
|
||||
return;
|
||||
}
|
||||
|
@ -5494,12 +5490,9 @@ Epplet_find_instance(const char *name)
|
|||
{
|
||||
if (mkdir(s, S_IRWXU) < 0)
|
||||
{
|
||||
char buf[255];
|
||||
|
||||
Esnprintf(buf, sizeof(buf),
|
||||
"Unable to create epplet config directory %s -- %s.\n",
|
||||
s, strerror(errno));
|
||||
Epplet_dialog_ok(buf);
|
||||
Epplet_dialog_ok
|
||||
("Unable to create epplet config directory %s -- %s.\n",
|
||||
s, strerror(errno));
|
||||
epplet_instance = 1;
|
||||
return;
|
||||
}
|
||||
|
@ -5695,12 +5688,8 @@ Epplet_save_config(void)
|
|||
|
||||
if (!(f = fopen(epplet_cfg_file, "w")))
|
||||
{
|
||||
char err[255];
|
||||
|
||||
Esnprintf(err, sizeof(err),
|
||||
"Unable to write to config file %s -- %s.\n",
|
||||
epplet_cfg_file, strerror(errno));
|
||||
Epplet_dialog_ok(err);
|
||||
Epplet_dialog_ok("Unable to write to config file %s -- %s.\n",
|
||||
epplet_cfg_file, strerror(errno));
|
||||
return;
|
||||
}
|
||||
fprintf(f, "### Automatically generated Epplet config file for %s.\n\n",
|
||||
|
|
|
@ -649,7 +649,7 @@ void Epplet_change_button_image(Epplet_gadget gadget,
|
|||
const char *image);
|
||||
void Epplet_clear_window(Window ww);
|
||||
void Epplet_show_about(const char *name);
|
||||
void Epplet_dialog_ok(const char *text);
|
||||
void Epplet_dialog_ok(const char *fmt, ...);
|
||||
int Epplet_get_hslider_clicked(Epplet_gadget gadget);
|
||||
int Epplet_get_vslider_clicked(Epplet_gadget gadget);
|
||||
|
||||
|
|
|
@ -292,7 +292,7 @@ static void
|
|||
parse_config(void)
|
||||
{
|
||||
const char *s;
|
||||
char buff[1024], ss[1024];
|
||||
char ss[1024];
|
||||
|
||||
image = Epplet_query_config_def("image", "8ball.png");
|
||||
|
||||
|
@ -301,9 +301,8 @@ parse_config(void)
|
|||
if (!parse_answers(ans_file) && !parse_answers(ans_file = ss))
|
||||
{
|
||||
/* Couldn't find the answers. Exit. */
|
||||
Esnprintf(buff, sizeof(buff),
|
||||
"E-Magic: Missing/invalid answers file \"%s\"", ans_file);
|
||||
Epplet_dialog_ok(buff);
|
||||
Epplet_dialog_ok("E-Magic: Missing/invalid answers file \"%s\"",
|
||||
ans_file);
|
||||
Esync();
|
||||
exit(-1);
|
||||
}
|
||||
|
|
|
@ -1127,9 +1127,7 @@ Mount(MountPoint * mp)
|
|||
}
|
||||
else
|
||||
{
|
||||
s[0] = 0;
|
||||
Esnprintf(s, sizeof(s), "Could not mount %s.", mp->path);
|
||||
Epplet_dialog_ok(s);
|
||||
Epplet_dialog_ok("Could not mount %s.", mp->path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1164,9 +1162,7 @@ Umount(MountPoint * mp)
|
|||
}
|
||||
else
|
||||
{
|
||||
s[0] = 0;
|
||||
Esnprintf(s, sizeof(s), "Could not unmount %s.", mp->path);
|
||||
Epplet_dialog_ok(s);
|
||||
Epplet_dialog_ok("Could not unmount %s.", mp->path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,12 +31,9 @@ cb_timer(void *data __UNUSED__)
|
|||
invalid = net_get_bytes_inout("eth0", &val, &val2);
|
||||
if (invalid)
|
||||
{
|
||||
char err[255];
|
||||
|
||||
Esnprintf(err, sizeof(err),
|
||||
"Unable to get network device statistics for eth0: %s",
|
||||
net_strerror(invalid));
|
||||
Epplet_dialog_ok(err);
|
||||
Epplet_dialog_ok
|
||||
("Unable to get network device statistics for eth0: %s",
|
||||
net_strerror(invalid));
|
||||
Epplet_unremember();
|
||||
Esync();
|
||||
exit(-1);
|
||||
|
|
|
@ -245,12 +245,8 @@ epplet_timer(void *data __UNUSED__)
|
|||
invalid = net_get_bytes_inout(netdev, &val, &val2);
|
||||
if (invalid)
|
||||
{
|
||||
char err[255];
|
||||
|
||||
Esnprintf(err, sizeof(err),
|
||||
"Unable to get network device statistics for %s: %s", netdev,
|
||||
net_strerror(invalid));
|
||||
Epplet_dialog_ok(err);
|
||||
Epplet_dialog_ok("Unable to get network device statistics for %s: %s",
|
||||
netdev, net_strerror(invalid));
|
||||
Epplet_unremember();
|
||||
Esync();
|
||||
exit(-1);
|
||||
|
|
|
@ -53,7 +53,6 @@ timer_draw(void *data __UNUSED__)
|
|||
float intensity;
|
||||
long elapsed_microseconds;
|
||||
struct timeval current_time;
|
||||
char err[255];
|
||||
|
||||
for (;
|
||||
(invalid =
|
||||
|
@ -62,10 +61,9 @@ timer_draw(void *data __UNUSED__)
|
|||
{
|
||||
if (ignore_no_dev == 0)
|
||||
{
|
||||
Esnprintf(err, sizeof(err),
|
||||
"Unable to get network device statistics for %s: %s",
|
||||
device_string, net_strerror(invalid));
|
||||
Epplet_dialog_ok(err);
|
||||
Epplet_dialog_ok
|
||||
("Unable to get network device statistics for %s: %s",
|
||||
device_string, net_strerror(invalid));
|
||||
Esync();
|
||||
config_cb(NULL);
|
||||
return;
|
||||
|
|
|
@ -266,13 +266,10 @@ change_image(void *data __UNUSED__)
|
|||
INC_PIC();
|
||||
if (idx == first)
|
||||
{
|
||||
char buff[256];
|
||||
|
||||
/* They're all NULL now. Time to give up. */
|
||||
Esnprintf(buff, sizeof(buff),
|
||||
"There don't seem to be any images in \"%s\". Please choose another directory.\n",
|
||||
path);
|
||||
Epplet_dialog_ok(buff);
|
||||
Epplet_dialog_ok
|
||||
("There don't seem to be any images in \"%s\". Please choose another directory.\n",
|
||||
path);
|
||||
Esync();
|
||||
config_cb(NULL);
|
||||
return;
|
||||
|
@ -663,11 +660,7 @@ get_images(char *image_path)
|
|||
temp = dirscan(image_path, &cnt);
|
||||
if (cnt == 0)
|
||||
{
|
||||
char err[255];
|
||||
|
||||
Esnprintf(err, sizeof(err), "Unable to find any files in %s!",
|
||||
image_path);
|
||||
Epplet_dialog_ok(err);
|
||||
Epplet_dialog_ok("Unable to find any files in %s!", image_path);
|
||||
Esync();
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue