[hackers] [scc] [driver] fix and simplify target tool name setting || Quentin Rameau

From: <git_AT_suckless.org>
Date: Mon, 23 Jan 2017 15:26:20 +0100 (CET)

commit b34aa2c27fb0724d6bd2ffda631feaa503122ed4
Author: Quentin Rameau <quinq_AT_fifth.space>
AuthorDate: Mon Jan 23 14:39:27 2017 +0100
Commit: Quentin Rameau <quinq_AT_fifth.space>
CommitDate: Mon Jan 23 14:48:15 2017 +0100

    [driver] fix and simplify target tool name setting

diff --git a/driver/posix/scc.c b/driver/posix/scc.c
index beaed6f..da1a441 100644
--- a/driver/posix/scc.c
+++ b/driver/posix/scc.c
_AT_@ -38,9 +38,9 @@ static struct tool {
         int in, out, init;
         pid_t pid;
 } tools[] = {
- [CC1] = { .bin = "cc1" },
+ [CC1] = { .cmd = "cc1" },
         [TEEIR] = { .bin = "tee", .cmd = "tee", },
- [CC2] = { .bin = "cc2" },
+ [CC2] = { .cmd = "cc2" },
         [TEEQBE] = { .bin = "tee", .cmd = "tee", },
         [QBE] = { .bin = "qbe", .cmd = "qbe", },
         [TEEAS] = { .bin = "tee", .cmd = "tee", },
_AT_@ -95,7 +95,6 @@ static int
 inittool(int tool)
 {
         struct tool *t = &tools[tool];
- size_t binln;
         int n;
 
         if (t->init)
_AT_@ -104,15 +103,11 @@ inittool(int tool)
         switch (tool) {
         case CC1: /* FALLTHROUGH */
         case CC2:
- binln = strlen(t->bin);
                 if (!arch)
                         arch = ARCH;
- n = snprintf(t->bin + binln,
- sizeof(t->bin) - binln,
- "-%s", arch);
+ n = snprintf(t->bin, sizeof(t->bin), "%s-%s", t->cmd, arch);
                 if (n < 0 || n >= sizeof(t->bin))
- die("scc: target tool bin too long");
- binln = strlen(t->bin);
+ die("scc: target tool name too long");
 
                 if (!execpath)
                         execpath = PREFIX "/libexec/scc";
Received on Mon Jan 23 2017 - 15:26:20 CET

This archive was generated by hypermail 2.3.0 : Mon Jan 23 2017 - 15:36:20 CET