Clean up string handling
[browser-switch] / main.c
diff --git a/main.c b/main.c
index 5429a59..5403b70 100644 (file)
--- a/main.c
+++ b/main.c
@@ -40,7 +40,7 @@
 
 struct swb_context ctx;
 
-static void set_config_defaults(struct swb_context * ctx) {
+static void set_config_defaults(struct swb_context *ctx) {
        if (!ctx)
                return;
        free(ctx->other_browser_cmd);
@@ -71,8 +71,7 @@ static void read_config(int signalnum) {
        len = strlen(homedir) + strlen(CONFIGFILE_LOC) + 1;
        if (!(configfile = calloc(len, sizeof(char))))
                goto out_noopen;
-       strncpy(configfile, homedir, strlen(homedir));
-       strncat(configfile, CONFIGFILE_LOC, strlen(CONFIGFILE_LOC));
+       snprintf(configfile, len, "%s%s", homedir, CONFIGFILE_LOC);
 
        if (!(fp = fopen(configfile, "r")))
                goto out_noopen;
@@ -162,9 +161,9 @@ out_noopen:
 }
 
 int main() {
-       OssoBrowser * obj;
-       GMainLoop * mainloop;
-       GError * error = NULL;
+       OssoBrowser *obj;
+       GMainLoop *mainloop;
+       GError *error = NULL;
 
        read_config(0);