aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2019-12-30 13:00:29 -0500
committerJoseph Hunkeler <jhunkeler@gmail.com>2019-12-30 13:00:29 -0500
commitd0e254663e64e40b676644038a9d7c95a2f25116 (patch)
tree193b9d0f5b58436b2ecbcb4762327c8560831a2b
parent4595ada2f69b42670c85a63c7d2344af63f2afe7 (diff)
downloadspmc-d0e254663e64e40b676644038a9d7c95a2f25116.tar.gz
Fix inane compiler warnings
* fix rpath_set * add rpath_autoset * add internal command "rpath_set"
-rw-r--r--include/spm.h8
-rw-r--r--src/CMakeLists.txt7
-rw-r--r--src/deps.c18
-rw-r--r--src/find.c2
-rw-r--r--src/fs.c9
-rw-r--r--src/install.c12
-rw-r--r--src/internal_cmd.c147
-rw-r--r--src/manifest.c10
-rw-r--r--src/relocation.c4
-rw-r--r--src/rpath.c46
-rw-r--r--src/spm.c6
-rw-r--r--src/strings.c10
-rw-r--r--src/version_spec.c8
13 files changed, 183 insertions, 104 deletions
diff --git a/include/spm.h b/include/spm.h
index 372cb20..59fad07 100644
--- a/include/spm.h
+++ b/include/spm.h
@@ -27,7 +27,7 @@
#include "config.h"
// spm.c
-#define SYSERROR stderr, "%s:%s:%d: %s\n", __FILE__, __FUNCTION__, __LINE__, strerror(errno)
+#define SYSERROR stderr, "%s:%s:%d: %s\n", basename(__FILE__), __FUNCTION__, __LINE__, strerror(errno)
#define DIRSEP_WIN32 '\\'
#define DIRSEP_UNIX '/'
#if defined(_WIN32)
@@ -159,13 +159,11 @@ char** split(char *sptr, const char* delim);
void split_free(char **ptr);
char *join(char **arr, const char *separator);
char *substring_between(char *sptr, const char *delims);
-static int _strsort_compare(const void *a, const void *b);
void strsort(char **arr);
int find_in_file(const char *filename, const char *pattern);
int isrelational(char ch);
void print_banner(const char *s, int len);
-
// find.c
char *find_executable(const char *program);
char *find_file(const char *root, const char *filename);
@@ -178,7 +176,8 @@ char *rpath_autodetect(const char *filename);
int has_rpath(const char *_filename);
char *rpath_get(const char *_filename);
char *rpath_generate(const char *_filename);
-int rpath_set(const char *filename, char *_rpath);
+int rpath_autoset(const char *filename);
+int rpath_set(const char *filename, const char *rpath);
// fs.c
int _fstree_compare(const FTSENT **a, const FTSENT **b);
@@ -248,7 +247,6 @@ int64_t version_suffix_modifier_calc(char *str);
int version_suffix_alpha_calc(char *str);
int64_t version_from(const char *version_str);
int version_spec_from(const char *op);
-static int _find_by_spec_compare(const void *a, const void *b);
ManifestPackage **find_by_spec(Manifest *manifest, const char *name, const char *op, const char *version_str);
// build.c
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 80fb9d9..8981122 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -5,6 +5,13 @@ include_directories(
add_executable(spm spm.c config.c compat.c deps.c fs.c rpath.c find.c shell.c archive.c strings.c relocation.c install.c config_global.c manifest.c checksum.c extern/url.c version_spec.c spm_build.c mime.c internal_cmd.c)
target_link_libraries(spm rt crypto ssl curl)
+
+if(MSVC)
+ target_compile_options(spm PRIVATE /W4 /WX)
+else()
+ target_compile_options(spm PRIVATE -Wall -Wextra)
+endif()
+
install(
TARGETS spm
DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
diff --git a/src/deps.c b/src/deps.c
index 071610d..037b75e 100644
--- a/src/deps.c
+++ b/src/deps.c
@@ -13,7 +13,7 @@ int dep_seen(Dependencies **deps, const char *name) {
if (!deps) {
return -1;
}
- for (int i = 0; i != (*deps)->records; i++) {
+ for (size_t i = 0; i != (*deps)->records; i++) {
if (strstr((*deps)->list[i], name) != NULL) {
return 1;
}
@@ -45,7 +45,7 @@ void dep_free(Dependencies **deps) {
if ((*deps) != NULL) {
return;
}
- for (int i = 0; i < (*deps)->__size; i++) {
+ for (size_t i = 0; i < (*deps)->__size; i++) {
if ((*deps)->list[i] != NULL) {
free((*deps)->list[i]);
}
@@ -163,27 +163,34 @@ int dep_all(Dependencies **deps, const char *_package) {
char *package = NULL;
char depfile[PATH_MAX];
char template[PATH_MAX];
- char suffix[PATH_MAX] = "spm_depends_all_XXXXXX";
+ char *suffix = (char *)calloc(PATH_MAX, sizeof(char));
+
+ memset(depfile, '\0', PATH_MAX);
+ memset(template, '\0', PATH_MAX);
+ strcpy(suffix, "spm_depends_all_XXXXXX");
// Verify the requested package pattern exists
package = find_package(_package);
if (!package) {
perror(_package);
fprintf(SYSERROR);
+ free(suffix);
return -1;
}
// Create a new temporary directory and extract the requested package into it
- sprintf(template, "%s%c%s", TMP_DIR, DIRSEP, suffix);
+ snprintf(template, PATH_MAX, "%s%c%s", TMP_DIR, DIRSEP, suffix);
char *tmpdir = mkdtemp(template);
if (!tmpdir) {
perror(template);
fprintf(SYSERROR);
+ free(suffix);
return -1;
}
if (tar_extract_file(package, ".SPM_DEPENDS", tmpdir) < 0) {
perror(package);
fprintf(SYSERROR);
+ free(suffix);
return -1;
}
@@ -204,6 +211,7 @@ int dep_all(Dependencies **deps, const char *_package) {
// Remove temporary data
unlink(depfile);
unlink(tmpdir);
+ free(suffix);
return 0;
}
@@ -215,7 +223,7 @@ void dep_show(Dependencies **deps) {
if ((*deps) == NULL) {
return;
}
- for (int i = 0; i < (*deps)->records; i++) {
+ for (size_t i = 0; i < (*deps)->records; i++) {
printf(" -> %s\n", (*deps)->list[i]);
}
}
diff --git a/src/find.c b/src/find.c
index 6db46e7..bc003dd 100644
--- a/src/find.c
+++ b/src/find.c
@@ -118,7 +118,7 @@ int find_in_file(const char *filename, const char *pattern) {
fread(buffer, (size_t) file_len, sizeof(char), fp);
fclose(fp);
- for (size_t i = 0; i < file_len; i++) {
+ for (size_t i = 0; i < (size_t) file_len; i++) {
if (!memcmp(&buffer[i], pattern, pattern_len)) {
result = 0; // found
break;
diff --git a/src/fs.c b/src/fs.c
index 93f625d..a9438d1 100644
--- a/src/fs.c
+++ b/src/fs.c
@@ -168,7 +168,7 @@ char *expandpath(const char *_path) {
strchrdel(ptmp, "~");
// Figure out where the user's home directory resides
- for (int i = 0; i < sizeof(homes); i++) {
+ for (size_t i = 0; i < sizeof(homes); i++) {
char *tmphome;
if ((tmphome = getenv(homes[i])) != NULL) {
strncpy(home, tmphome, strlen(tmphome));
@@ -286,16 +286,15 @@ int rsync(const char *_args, const char *_source, const char *_destination) {
char *source = strdup(_source);
char *destination = strdup(_destination);
char cmd[PATH_MAX];
- char args_combined[PATH_MAX];
+ char *args_combined = (char *)calloc(PATH_MAX, sizeof(char));
memset(cmd, '\0', sizeof(cmd));
- memset(args_combined, '\0', sizeof(args_combined));
strcpy(args_combined, "--archive --hard-links ");
if (args) {
strcat(args_combined, _args);
}
- sprintf(cmd, "rsync %s \"%s\" \"%s\"", args_combined, source, destination);
+ snprintf(cmd, PATH_MAX, "rsync %s \"%s\" \"%s\"", args_combined, source, destination);
// sanitize command
strchrdel(cmd, "&;|");
shell(&proc, SHELL_OUTPUT, cmd);
@@ -402,7 +401,7 @@ int exists(const char *filename) {
* @return string
*/
char *human_readable_size(uint64_t n) {
- int i;
+ size_t i;
double result = (double)n;
char *unit[] = {"B", "K", "M", "G", "T", "P", "E"};
char r[255];
diff --git a/src/install.c b/src/install.c
index 1fb4513..7d41b36 100644
--- a/src/install.c
+++ b/src/install.c
@@ -63,8 +63,16 @@ int install(const char *destroot, const char *_package) {
char cwd[PATH_MAX];
char source[PATH_MAX];
char template[PATH_MAX];
- char suffix[PATH_MAX] = "spm_destroot_XXXXXX";
- sprintf(template, "%s%c%s", TMP_DIR, DIRSEP, suffix);
+
+ // circumvent -Wformat-truncation
+ char *suffix = (char *) calloc(PATH_MAX, sizeof(char));
+ if (!suffix) {
+ perror("suffix");
+ fprintf(SYSERROR);
+ }
+ strcpy(suffix, "spm_destroot_XXXXXX");
+ snprintf(template, PATH_MAX, "%s%c%s", TMP_DIR, DIRSEP, suffix);
+ free(suffix);
// Create a new temporary directory and extract the requested package into it
char *tmpdir = mkdtemp(template);
diff --git a/src/internal_cmd.c b/src/internal_cmd.c
index 7869c53..38456cf 100644
--- a/src/internal_cmd.c
+++ b/src/internal_cmd.c
@@ -9,9 +9,97 @@
static char *internal_commands[] = {
"mkprefixbin", "generate prefix manifest (binary)",
"mkprefixtext", "generate prefix manifest (text)",
+ "rpath_set", "modify binary RPATH",
NULL, NULL,
};
+void mkprefix_interface_usage(void) {
+ printf("usage: mkprefix[bin|text] {output_file} {dir} {prefix ...}\n");
+}
+
+int mkprefix_interface(int argc, char **argv) {
+ char *command = argv[0];
+ char *outfile = argv[1];
+ char *tree = argv[2];
+
+ size_t prefix_start = 3;
+ size_t prefixes = 0;
+ for (size_t i = prefix_start; i < (size_t) argc; i++) {
+ prefixes = i;
+ }
+
+ // Check arguments
+ if (!outfile) {
+ fprintf(stderr, "error: missing output file name\n");
+ mkprefix_interface_usage();
+ return -1;
+ }
+ if (!tree) {
+ fprintf(stderr, "error: missing directory path\n");
+ mkprefix_interface_usage();
+ return -1;
+ }
+ if (!prefixes) {
+ fprintf(stderr, "error: missing prefix string(s)\n");
+ mkprefix_interface_usage();
+ return -1;
+ }
+
+ char **prefix = (char **) calloc(prefixes + 1, sizeof(char *));
+ if (!prefix) {
+ perror("prefix array");
+ fprintf(SYSERROR);
+ return -1;
+ }
+
+ // Populate array of prefixes; reusing pointers from argv
+ for (size_t i = 0; (i + prefix_start) < (size_t) argc; i++) {
+ prefix[i] = argv[(i + prefix_start)];
+ }
+
+ if (SPM_GLOBAL.verbose) {
+ printf("Generating prefix manifest: %s\n", outfile);
+ }
+
+ int result;
+ if (strcmp(command, "mkprefixbin") == 0) {
+ result = prefixes_write(outfile, PREFIX_WRITE_BIN, prefix, tree);
+ } else if (strcmp(command, "mkprefixtext") == 0) {
+ result = prefixes_write(outfile, PREFIX_WRITE_TEXT, prefix, tree);
+ }
+ return result;
+}
+
+/**
+ *
+ */
+void rpath_set_interface_usage(void) {
+ printf("usage: rpath_set {file} {rpath}\n");
+}
+
+/**
+ *
+ * @param argc
+ * @param argv
+ * @return
+ */
+int rpath_set_interface(int argc, char **argv) {
+ for (int i = 0; i < argc; i++) {
+ printf("argv[%d] = %s\n", i, argv[i]);
+ }
+ if (argc < 3) {
+ rpath_set_interface_usage();
+ return -1;
+ }
+ char *filename = argv[1];
+ char *rpath = argv[2];
+ int result = rpath_set(filename, rpath);
+ if (result < 0) {
+ fprintf(SYSERROR);
+ }
+ return result;
+}
+
/**
* Show a listing of valid internal commands
*/
@@ -23,10 +111,6 @@ void internal_command_list(void) {
}
}
-void mkprefix_usage(void) {
- printf("usage: mkprefix[bin|text] {output_file} {dir} {prefix ...}\n");
-}
-
/**
* Execute an internal command
* @param argc
@@ -54,54 +138,15 @@ int internal_cmd(int argc, char **argv) {
return 1;
}
- if (strcmp(command, "mkprefixbin") == 0 || strcmp(command, "mkprefixtext") == 0) {
- char *outfile = argv[2];
- char *tree = argv[3];
-
- size_t prefix_start = 4;
- size_t prefixes = 0;
- for (size_t i = prefix_start; i < argc; i++) {
- prefixes = i;
- }
+ // Strip the first argument (this level) before passing it along to the interface
+ int arg_count = argc - 1;
+ char **arg_array = &argv[1];
- // Check arguments
- if (!outfile) {
- fprintf(stderr, "error: missing output file name\n");
- mkprefix_usage();
- return -1;
- }
- if (!tree) {
- fprintf(stderr, "error: missing directory path\n");
- mkprefix_usage();
- return -1;
- }
- if (!prefixes) {
- fprintf(stderr, "error: missing prefix string(s)\n");
- mkprefix_usage();
- return -1;
- }
-
- char **prefix = (char **) calloc(prefixes + 1, sizeof(char *));
- if (!prefix) {
- perror("prefix array");
- fprintf(SYSERROR);
- return -1;
- }
-
- // Populate array of prefixes; reusing pointers from argv
- for (int i = 0; (i + prefix_start) < argc; i++) {
- prefix[i] = argv[(i + prefix_start)];
- }
-
- if (SPM_GLOBAL.verbose) {
- printf("Generating prefix manifest: %s\n", outfile);
- }
-
- if (strcmp(command, "mkprefixbin") == 0) {
- prefixes_write(outfile, PREFIX_WRITE_BIN, prefix, tree);
- } else if (strcmp(command, "mkprefixtext") == 0) {
- prefixes_write(outfile, PREFIX_WRITE_TEXT, prefix, tree);
- }
+ if (strcmp(command, "mkprefixbin") == 0 || strcmp(command, "mkprefixtext") == 0) {
+ return mkprefix_interface(arg_count, arg_array);
+ }
+ else if (strcmp(command, "rpath_set") == 0) {
+ return rpath_set_interface(arg_count, arg_array);
}
return 0;
} \ No newline at end of file
diff --git a/src/manifest.c b/src/manifest.c
index 240ce8e..f889de2 100644
--- a/src/manifest.c
+++ b/src/manifest.c
@@ -34,7 +34,7 @@ Manifest *manifest_from(const char *package_dir) {
if (deps->records) {
info->packages[i]->requirements = (char **) calloc(deps->__size, sizeof(char *));
info->packages[i]->requirements_records = deps->records;
- int j;
+ size_t j;
for (j = 0; j < deps->records; j++) {
info->packages[i]->requirements[j] = (char *) calloc(strlen(deps->list[j]) + 1, sizeof(char));
strncpy(info->packages[i]->requirements[j], deps->list[j], strlen(deps->list[j]));
@@ -81,7 +81,7 @@ Manifest *manifest_from(const char *package_dir) {
* @param info `Manifest`
*/
void manifest_free(Manifest *info) {
- for (int i = 0; i < info->records; i++) {
+ for (size_t i = 0; i < info->records; i++) {
if (info->packages[i]->requirements) {
for (int j = 0; info->packages[i]->requirements[j] != NULL; j++) {
free(info->packages[i]->requirements[j]);
@@ -109,7 +109,7 @@ int manifest_write(Manifest *info) {
// A little too much information (debug?)
if (SPM_GLOBAL.verbose) {
- for (int i = 0; i < info->records; i++) {
+ for (size_t i = 0; i < info->records; i++) {
printf("%-20s: %s\n"
"%-20s: %zu\n"
"%-20s: %s\n"
@@ -131,7 +131,7 @@ int manifest_write(Manifest *info) {
}
printf("Generating manifest file: %s\n", path);
- for (int i = 0; i < info->records; i++) {
+ for (size_t i = 0; i < info->records; i++) {
// write CSV-like manifest
char data[BUFSIZ];
memset(data, '\0', BUFSIZ);
@@ -229,7 +229,7 @@ ManifestPackage *manifest_search(Manifest *info, const char *_package) {
strncpy(package, _package, PATH_MAX);
strcat(package, "*");
- for (int i = 0; i < info->records; i++) {
+ for (size_t i = 0; i < info->records; i++) {
if (fnmatch(package, info->packages[i]->archive, FNM_PATHNAME) == 0) {
return info->packages[i];
}
diff --git a/src/relocation.c b/src/relocation.c
index a1c0056..9d627e4 100644
--- a/src/relocation.c
+++ b/src/relocation.c
@@ -160,7 +160,7 @@ RelocationEntry **prefixes_read(const char *filename) {
if (!entry) {
return NULL;
}
- for (int i = 0; i < record_count; i++) {
+ for (size_t i = 0; i < record_count; i++) {
entry[i] = (RelocationEntry *) calloc(1, sizeof(RelocationEntry));
if (!entry[i]) {
return NULL;
@@ -259,7 +259,7 @@ int prefixes_write(const char *output_file, int mode, char **prefix, const char
fprintf(SYSERROR);
return -1;
}
- for (int i = 0; i < fsdata->files_length; i++) {
+ for (size_t i = 0; i < fsdata->files_length; i++) {
for (int p = 0; prefix[p] != NULL; p++) {
if (find_in_file(fsdata->files[i], prefix[p]) == 0) {
int proceed = 0;
diff --git a/src/rpath.c b/src/rpath.c
index 1d32ae7..8953716 100644
--- a/src/rpath.c
+++ b/src/rpath.c
@@ -137,44 +137,56 @@ char *rpath_generate(const char *_filename) {
/**
* Set the RPATH of an executable
* @param filename
- * @param _rpath
+ * @param rpath
* @return
*/
-int rpath_set(const char *filename, char *_rpath) {
+int rpath_set(const char *filename, const char *rpath) {
int returncode = 0;
-
- char *rpath_new = rpath_generate(filename);
- if (!rpath_new) {
- return -1;
- }
-
char *rpath_orig = rpath_get(filename);
if (!rpath_orig) {
return -1;
}
// Are the original and new RPATH identical?
- if (strcmp(rpath_orig, rpath_new) == 0) {
- free(rpath_new);
+ if (strcmp(rpath_orig, rpath) == 0) {
free(rpath_orig);
return 0;
}
char args[PATH_MAX];
memset(args, '\0', PATH_MAX);
- sprintf(args, "--set-rpath \"%s\"", _rpath);
+ sprintf(args, "--set-rpath \"%s\"", rpath);
Process *pe = patchelf(filename, args);
if (pe != NULL) {
returncode = pe->returncode;
}
shell_free(pe);
- free(rpath_new);
free(rpath_orig);
return returncode;
}
/**
+ * Automatically detect the nearest lib directory and set the RPATH of an executable
+ * @param filename
+ * @param _rpath
+ * @return
+ */
+int rpath_autoset(const char *filename) {
+ int returncode = 0;
+
+ char *rpath_new = rpath_generate(filename);
+ if (!rpath_new) {
+ return -1;
+ }
+
+ returncode = rpath_set(filename, rpath_new);
+ free(rpath_new);
+
+ return returncode;
+}
+
+/**
* Using `filename` as a starting point, step backward through the filesystem looking for a lib directory
* @param filename path to file (or a directory)
* @return success=relative path from `filename` to nearest lib directory, failure=NULL
@@ -189,22 +201,23 @@ char *rpath_autodetect(const char *filename) {
// Change directory to the requested root
chdir(start);
- char visit[PATH_MAX]; // Current directory
+ char *visit = calloc(PATH_MAX, sizeof(char)); // Current directory
char tmp[PATH_MAX]; // Current directory with lib directory appended
char relative[PATH_MAX]; // Generated relative path to lib directory
char sep[2]; // Holds the platform's directory separator
// Initialize character arrays;
- visit[0] = '\0';
tmp[0] = '\0';
relative[0] = '\0';
sprintf(sep, "%c", DIRSEP);
while(1) {
// Where are we in the file system?
- getcwd(visit, sizeof(visit));
+ if((visit = getcwd(NULL, PATH_MAX)) == NULL) {
+ exit(errno);
+ }
// Using the current visit path, check if it contains a lib directory
- sprintf(tmp, "%s%clib", visit, DIRSEP);
+ snprintf(tmp, PATH_MAX, "%s%c%s", visit, DIRSEP, "lib");
if (access(tmp, F_OK) == 0) {
strcat(relative, "lib");
has_real_libdir = 1; // gate for memory allocation below
@@ -221,6 +234,7 @@ char *rpath_autodetect(const char *filename) {
// Step one directory level back
chdir("..");
+ free(visit);
}
// If we found a viable lib directory, allocate memory for it
diff --git a/src/spm.c b/src/spm.c
index 4a9ea2f..11ad736 100644
--- a/src/spm.c
+++ b/src/spm.c
@@ -200,12 +200,12 @@ int main(int argc, char *argv[]) {
if (deps) {
// List requirements before installation
- for (int i = 0; i < deps->records; i++) {
+ for (size_t i = 0; i < deps->records; i++) {
printf(" -> %s\n", deps->list[i]);
}
printf("Installing package requirements:\n");
- for (int i = 0; i < deps->records; i++) {
+ for (size_t i = 0; i < deps->records; i++) {
printf(" -> %s\n", deps->list[i]);
if (install(root, deps->list[i]) < 0) {
fprintf(SYSERROR);
@@ -306,7 +306,7 @@ int main(int argc, char *argv[]) {
}
}
else if(RUNTIME_LIST) {
- for (int p = 0; p < info->records; p++) {
+ for (size_t p = 0; p < info->records; p++) {
char *package_hsize = human_readable_size(info->packages[p]->size);
printf(" %-20s %-20s %-20s %-20s\n", info->packages[p]->name, info->packages[p]->version, info->packages[p]->revision, package_hsize);
free(package_hsize);
diff --git a/src/strings.c b/src/strings.c
index 782d66c..95068d0 100644
--- a/src/strings.c
+++ b/src/strings.c
@@ -177,7 +177,7 @@ char** split(char *_sptr, const char* delim)
free(sptr);
return NULL;
}
- strncpy(result[i], token, strlen(token)); // copy the string contents into the record
+ memcpy(result[i], token, strlen(token) + 1); // copy the string contents into the record
i++; // next record
}
free(orig);
@@ -402,7 +402,7 @@ char **strdeldup(char **arr) {
}
int rec = 0;
- int i = 0;
+ size_t i = 0;
while(i < records) {
// Search for value in results
if (strstr_array(result, arr[i]) == 0) {
@@ -417,7 +417,7 @@ char **strdeldup(char **arr) {
free(result);
return NULL;
}
- strncpy(result[rec], arr[i], strlen(arr[i]));
+ memcpy(result[rec], arr[i], strlen(arr[i]) + 1);
i++;
rec++;
}
@@ -526,8 +526,8 @@ void print_banner(const char *s, int len) {
if (!s_len) {
return;
}
- for (int i = 0; i < (len / s_len); i++) {
- for (int c = 0; c < s_len; c++) {
+ for (size_t i = 0; i < (len / s_len); i++) {
+ for (size_t c = 0; c < s_len; c++) {
putchar(s[c]);
}
}
diff --git a/src/version_spec.c b/src/version_spec.c
index 57b86c4..0249375 100644
--- a/src/version_spec.c
+++ b/src/version_spec.c
@@ -171,7 +171,7 @@ int64_t version_from(const char *version_str) {
// populate the head (numeric characters)
strncpy(head, x, strlen(x));
- for (int i = 0; i < strlen(head); i++) {
+ for (size_t i = 0; i < strlen(head); i++) {
if (isalpha(head[i])) {
// populate the tail (alphabetic characters)
strncpy(tail, &head[i], strlen(&head[i]));
@@ -235,7 +235,7 @@ int64_t version_from(const char *version_str) {
int version_spec_from(const char *op) {
int flags = VERSION_NOOP;
size_t len = strlen(op);
- for (int i = 0; i < len; i++) {
+ for (size_t i = 0; i < len; i++) {
if (op[i] == '>') {
flags |= VERSION_GT;
}
@@ -286,7 +286,7 @@ ManifestPackage **find_by_spec(Manifest *manifest, const char *name, const char
return NULL;
}
- for (int i = 0; i < manifest->records; i++) {
+ for (size_t i = 0; i < manifest->records; i++) {
if (strcmp(manifest->packages[i]->name, name) == 0) {
int64_t version_a = version_from(manifest->packages[i]->version);
int64_t version_b = version_from(version_str);
@@ -326,7 +326,7 @@ ManifestPackage **find_by_spec(Manifest *manifest, const char *name, const char
memcpy(list[record], manifest->packages[i], sizeof(ManifestPackage));
list[record]->requirements = (char **) calloc(manifest->packages[i]->requirements_records, sizeof(char *));
- for (int j = 0; j < manifest->packages[i]->requirements_records; j++) {
+ for (size_t j = 0; j < manifest->packages[i]->requirements_records; j++) {
list[record]->requirements[j] = (char *) calloc(strlen(manifest->packages[i]->requirements[j]) + 1, sizeof(char));
strncpy(list[record]->requirements[j], manifest->packages[i]->requirements[j], strlen(manifest->packages[i]->requirements[j]));
}