From 29ff2b99c47dd0d475c59696f3d749e4ad47999f Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Thu, 13 Jul 2017 15:54:16 +0200 Subject: [PATCH] Avoid a strlen() call --- client/powerline.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client/powerline.c b/client/powerline.c index edee6d30..ff107ece 100644 --- a/client/powerline.c +++ b/client/powerline.c @@ -88,6 +88,7 @@ int main(int argc, char *argv[]) { char *wd = NULL; char **envp; const char *address; + int len; if (argc < 2) { printf("Must provide at least one argument.\n"); @@ -122,8 +123,8 @@ int main(int argc, char *argv[]) { execvp("powerline-render", newargv); } - snprintf(num_args, NUM_ARGS_SIZE, "%x", argc - 1); - do_write(sd, num_args, strlen(num_args)); + len = snprintf(num_args, NUM_ARGS_SIZE, "%x", argc - 1); + do_write(sd, num_args, len); do_write(sd, eof, 1); for (i = 1; i < argc; i++) {