Code

screen_keydef: get rid of the BUFSIZE constant
authorJonathan Neuschäfer <j.neuschaefer@gmx.net>
Sat, 24 Dec 2011 17:28:04 +0000 (18:28 +0100)
committerJonathan Neuschäfer <j.neuschaefer@gmx.net>
Sat, 24 Dec 2011 17:28:04 +0000 (18:28 +0100)
It was only used in one function. Use sizeof(buf) instead.

src/screen_keydef.c

index 800e54f4b807f5783bafb6484bed0dd01badcdda..0f46eee85fbf5e90572013dc479afedfc8e50713 100644 (file)
@@ -33,7 +33,6 @@
 
 #define STATIC_ITEMS      0
 #define STATIC_SUB_ITEMS  1
-#define BUFSIZE 256
 
 #define LIST_ITEM_APPLY()   ((unsigned)command_list_length)
 #define LIST_ITEM_SAVE()    (LIST_ITEM_APPLY()+1)
@@ -203,7 +202,7 @@ assign_new_key(int cmd_index, int key_index)
 static const char *
 list_callback(unsigned idx, G_GNUC_UNUSED void *data)
 {
-       static char buf[BUFSIZE];
+       static char buf[256];
 
        if (subcmd < 0) {
                if (idx == LIST_ITEM_APPLY())
@@ -219,15 +218,15 @@ list_callback(unsigned idx, G_GNUC_UNUSED void *data)
                        return "[..]";
                idx--;
                if (idx == subcmd_addpos) {
-                       g_snprintf(buf, BUFSIZE, "%d. %s",
+                       g_snprintf(buf, sizeof(buf), "%d. %s",
                                   idx + 1, _("Add new key"));
                        return buf;
                }
 
                assert(idx < MAX_COMMAND_KEYS && cmds[subcmd].keys[idx] > 0);
 
-               g_snprintf(buf,
-                          BUFSIZE, "%d. %-20s   (%d) ",
+               g_snprintf(buf, sizeof(buf),
+                          "%d. %-20s   (%d) ",
                           idx + 1,
                           key2str(cmds[subcmd].keys[idx]),
                           cmds[subcmd].keys[idx]);