Cast first argument for %.*s to int
[strongswan.git] / src / libimcv / plugins / imv_os / pacman.c
index eef5ce0..f5f5288 100644 (file)
@@ -97,13 +97,13 @@ static time_t extract_time(char *line)
        char* months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
                                           "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
        int i;
-       
+
        if (sscanf(line, "Generated: %3s %3s %2d %2d:%2d:%2d %4d UTC", wday, mon,
                           &t.tm_mday, &t.tm_hour, &t.tm_min, &t.tm_sec, &t.tm_year) != 7)
        {
                return UNDEFINED_TIME;
        }
-       t.tm_isdst = 0; 
+       t.tm_isdst = 0;
        t.tm_year -= 1900;
        t.tm_mon = 12;
 
@@ -173,7 +173,7 @@ static void process_packages(char *filename, char *product, bool update)
                e->destroy(e);
        }
        if (!pid)
-       {       
+       {
                if (db->execute(db, &pid, "INSERT INTO products (name) VALUES (?)",
                                                DB_TEXT, product) != 1)
                {
@@ -221,8 +221,8 @@ static void process_packages(char *filename, char *product, bool update)
                pos = strchr(line, ' ');
                if (!pos)
                {
-                       fprintf(stderr, "could not extract package name from '%.*s'",
-                                       strlen(line)-1, line);
+                       fprintf(stderr, "could not extract package name from '%.*s'\n",
+                                       (int)(strlen(line)-1), line);
                        errored++;
                        continue;
                }
@@ -240,8 +240,8 @@ static void process_packages(char *filename, char *product, bool update)
                        }
                        else
                        {
-                               fprintf(stderr, "could not extract package version from '%.*s'\n",
-                                       strlen(line)-1, line);
+                               fprintf(stderr, "could not extract package version from "
+                                               "'%.*s'\n", (int)(strlen(line)-1), line);
                                errored++;
                                continue;
                        }
@@ -275,7 +275,7 @@ static void process_packages(char *filename, char *product, bool update)
                        e->destroy(e);
                }
                if (!gid && security)
-               {       
+               {
                        if (db->execute(db, &gid, "INSERT INTO packages (name) VALUES (?)",
                                                                DB_TEXT, package) != 1)
                        {
@@ -289,7 +289,7 @@ static void process_packages(char *filename, char *product, bool update)
                }
 
                /* check for package versions already in database */
-               e = db->query(db, 
+               e = db->query(db,
                                "SELECT id, release, security, time FROM versions "
                                "WHERE package = ? AND product = ?",
                                DB_INT, gid, DB_INT, pid, DB_INT, DB_TEXT, DB_INT, DB_INT);
@@ -344,11 +344,13 @@ static void process_packages(char *filename, char *product, bool update)
 
                if ((!vid && !security) || (vid && !add_version))
                {
+                       free(version_update);
+                       free(version_delete);
                        continue;
                }
 
                if ((!vid && security) || (vid && !vid_update))
-               {       
+               {
                        printf("%s (%s) %s\n", package, version, security ? "[s]" : "");
 
                        if (db->execute(db, &vid,
@@ -359,6 +361,8 @@ static void process_packages(char *filename, char *product, bool update)
                        {
                                fprintf(stderr, "could not store version '%s' to database\n",
                                                                 version);
+                               free(version_update);
+                               free(version_delete);
                                fclose(file);
                                db->destroy(db);
                                exit(EXIT_FAILURE);
@@ -377,6 +381,8 @@ static void process_packages(char *filename, char *product, bool update)
                        {
                                fprintf(stderr, "could not update version '%s' to database\n",
                                                                 version);
+                               free(version_update);
+                               free(version_delete);
                                fclose(file);
                                db->destroy(db);
                                exit(EXIT_FAILURE);
@@ -395,6 +401,8 @@ static void process_packages(char *filename, char *product, bool update)
                        {
                                fprintf(stderr, "could not delete version '%s' from database\n",
                                                                 version_delete);
+                               free(version_update);
+                               free(version_delete);
                                fclose(file);
                                db->destroy(db);
                                exit(EXIT_FAILURE);