Fixed -Wsign-compare.

This commit is contained in:
TheDarkBug 2021-03-19 17:28:09 +01:00
parent 7f26eb72f9
commit 3ada75bbaa

View file

@ -91,25 +91,25 @@ int pkgman() { // this is just a function that returns the total of installed pa
// TODO: should this be at the top of the program? maybe in a config.c file? // TODO: should this be at the top of the program? maybe in a config.c file?
// TODO: do we need to `free()` this? I have no idea how to do memory management in C... // TODO: do we need to `free()` this? I have no idea how to do memory management in C...
struct package_manager { struct package_manager {
char command_string[128]; // command to get number of packages installed char command_string[128]; // command to get number of packages installed
char pkgman_name[16]; // name of the package manager char pkgman_name[16]; // name of the package manager
}; };
struct package_manager pkgmans[] = { struct package_manager pkgmans[] = {
{ "apk info 2> /dev/null | wc -l", "(apk)" }, { "apk info 2> /dev/null | wc -l", "(apk)" },
{ "dnf list installed 2> /dev/null | wc -l", "(dnf)" }, { "dnf list installed 2> /dev/null | wc -l", "(dnf)" },
{ "qlist -I 2> /dev/null | wc -l", "(emerge)" }, { "qlist -I 2> /dev/null | wc -l", "(emerge)" },
{ "flatpak list 2> /dev/null | wc -l", "(flatpack)" }, { "flatpak list 2> /dev/null | wc -l", "(flatpack)" },
{ "guix package --list-installed 2> /dev/null | wc -l", "(guix)" }, { "guix package --list-installed 2> /dev/null | wc -l", "(guix)" },
{ "nix-store -q --requisites /run/current-sys_vartem/sw 2> /dev/null | wc -l", "(nix)" }, { "nix-store -q --requisites /run/current-sys_vartem/sw 2> /dev/null | wc -l", "(nix)" },
{ "pacman -Qq 2> /dev/null | wc -l", "(pacman)" }, { "pacman -Qq 2> /dev/null | wc -l", "(pacman)" },
{ "rpm -qa --last 2> /dev/null | wc -l", "(rpm)" }, { "rpm -qa --last 2> /dev/null | wc -l", "(rpm)" },
{ "xbps-query -l 2> /dev/null | wc -l", "(xbps)" }, { "xbps-query -l 2> /dev/null | wc -l", "(xbps)" }
}; };
const unsigned long pkgman_count = sizeof(pkgmans) / sizeof(pkgmans[0]); const unsigned long pkgman_count = sizeof(pkgmans) / sizeof(pkgmans[0]);
for (int i = 0; i < pkgman_count; i++) { for (long unsigned int i = 0; i < pkgman_count; i++) { // long unsigned int instead of int because of -Wsign-compare
struct package_manager *current = &pkgmans[i]; struct package_manager *current = &pkgmans[i];
FILE *fp = popen(current->command_string, "r"); FILE *fp = popen(current->command_string, "r");
@ -121,7 +121,6 @@ int pkgman() { // this is just a function that returns the total of installed pa
total += pkg_count; total += pkg_count;
if (pkg_count > 0) strcat(pkgman_name, current->pkgman_name); if (pkg_count > 0) strcat(pkgman_name, current->pkgman_name);
} }
return total; return total;
} }