summaryrefslogtreecommitdiffhomepage
path: root/src/codegen.c
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2012-06-26 22:41:48 -0700
committerYukihiro "Matz" Matsumoto <[email protected]>2012-06-26 22:41:48 -0700
commit7c64a2be8dc070835f8dde125cb4d48b7b198c23 (patch)
tree4a68ccdafa027f2679acdd0e34e6f571d30241b8 /src/codegen.c
parentcf8b6ec8418ce3970a82b80d514a17b0ffa61b53 (diff)
parent2042684b6ed163ca1ebfdaaffe5bd7e98b19abc6 (diff)
downloadmruby-7c64a2be8dc070835f8dde125cb4d48b7b198c23.tar.gz
mruby-7c64a2be8dc070835f8dde125cb4d48b7b198c23.zip
Merge pull request #329 from monaka/pr-reduce-magic-number-in-snprintf
Use sizeof to get char array sizes.
Diffstat (limited to 'src/codegen.c')
-rw-r--r--src/codegen.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/codegen.c b/src/codegen.c
index cbf401a1f..fb0006625 100644
--- a/src/codegen.c
+++ b/src/codegen.c
@@ -1537,7 +1537,7 @@ codegen(codegen_scope *s, node *tree, int val)
int len;
int sym;
- len = snprintf(buf, 3, "$%c", (int)(intptr_t)tree);
+ len = snprintf(buf, sizeof(buf), "$%c", (int)(intptr_t)tree);
sym = new_sym(s, mrb_intern2(s->mrb, buf, len));
genop(s, MKOP_ABx(OP_GETGLOBAL, cursp(), sym));
push();
@@ -1550,7 +1550,7 @@ codegen(codegen_scope *s, node *tree, int val)
int len;
int sym;
- len = snprintf(buf, 3, "$%d", (int)(intptr_t)tree);
+ len = snprintf(buf, sizeof(buf), "$%d", (int)(intptr_t)tree);
sym = new_sym(s, mrb_intern2(s->mrb, buf, len));
genop(s, MKOP_ABx(OP_GETGLOBAL, cursp(), sym));
push();