summaryrefslogtreecommitdiffstats
path: root/plugins/check_apt.c
diff options
context:
space:
mode:
authorLorenz Kästle <12514511+RincewindsHat@users.noreply.github.com>2023-10-29 10:09:00 (GMT)
committerGitHub <noreply@github.com>2023-10-29 10:09:00 (GMT)
commit77e38ac1c025b8431d1834a2c1059f9677c78ab1 (patch)
treeaa8dc016303530e56155826f355cb7e3c3a4ee94 /plugins/check_apt.c
parent2eea6bb2a04bbfb169bac5f0f7c319f998e8ab87 (diff)
parenteead88edda047843b911afd7b63e7decfee306ce (diff)
downloadmonitoring-plugins-77e38ac1c025b8431d1834a2c1059f9677c78ab1.tar.gz
Merge pull request #1953 from RincewindsHat/compiler_warnings-sign-compare
Fixes for -Wsign-compare
Diffstat (limited to 'plugins/check_apt.c')
-rw-r--r--plugins/check_apt.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/plugins/check_apt.c b/plugins/check_apt.c
index fa982ae..5c0f6e2 100644
--- a/plugins/check_apt.c
+++ b/plugins/check_apt.c
@@ -94,7 +94,7 @@ static int stderr_warning = 0; /* if a cmd issued output on stderr */
94static int exec_warning = 0; /* if a cmd exited non-zero */ 94static int exec_warning = 0; /* if a cmd exited non-zero */
95 95
96int main (int argc, char **argv) { 96int main (int argc, char **argv) {
97 int result=STATE_UNKNOWN, packages_available=0, sec_count=0, i=0; 97 int result=STATE_UNKNOWN, packages_available=0, sec_count=0;
98 char **packages_list=NULL, **secpackages_list=NULL; 98 char **packages_list=NULL, **secpackages_list=NULL;
99 99
100 /* Parse extra opts if any */ 100 /* Parse extra opts if any */
@@ -142,10 +142,11 @@ int main (int argc, char **argv) {
142 qsort(secpackages_list, sec_count, sizeof(char*), cmpstringp); 142 qsort(secpackages_list, sec_count, sizeof(char*), cmpstringp);
143 qsort(packages_list, packages_available-sec_count, sizeof(char*), cmpstringp); 143 qsort(packages_list, packages_available-sec_count, sizeof(char*), cmpstringp);
144 144
145 for(i = 0; i < sec_count; i++) 145 for(int i = 0; i < sec_count; i++)
146 printf("%s (security)\n", secpackages_list[i]); 146 printf("%s (security)\n", secpackages_list[i]);
147
147 if (only_critical == false) { 148 if (only_critical == false) {
148 for(i = 0; i < packages_available - sec_count; i++) 149 for(int i = 0; i < packages_available - sec_count; i++)
149 printf("%s\n", packages_list[i]); 150 printf("%s\n", packages_list[i]);
150 } 151 }
151 } 152 }
@@ -251,7 +252,7 @@ int process_arguments (int argc, char **argv) {
251 252
252/* run an apt-get upgrade */ 253/* run an apt-get upgrade */
253int run_upgrade(int *pkgcount, int *secpkgcount, char ***pkglist, char ***secpkglist){ 254int run_upgrade(int *pkgcount, int *secpkgcount, char ***pkglist, char ***secpkglist){
254 int i=0, result=STATE_UNKNOWN, regres=0, pc=0, spc=0; 255 int result=STATE_UNKNOWN, regres=0, pc=0, spc=0;
255 struct output chld_out, chld_err; 256 struct output chld_out, chld_err;
256 regex_t ireg, ereg, sreg; 257 regex_t ireg, ereg, sreg;
257 char *cmdline=NULL, rerrbuf[64]; 258 char *cmdline=NULL, rerrbuf[64];
@@ -320,7 +321,7 @@ int run_upgrade(int *pkgcount, int *secpkgcount, char ***pkglist, char ***secpkg
320 * we may need to switch to the --print-uris output format, 321 * we may need to switch to the --print-uris output format,
321 * in which case the logic here will slightly change. 322 * in which case the logic here will slightly change.
322 */ 323 */
323 for(i = 0; i < chld_out.lines; i++) { 324 for(size_t i = 0; i < chld_out.lines; i++) {
324 if(verbose){ 325 if(verbose){
325 printf("%s\n", chld_out.line[i]); 326 printf("%s\n", chld_out.line[i]);
326 } 327 }
@@ -353,7 +354,7 @@ int run_upgrade(int *pkgcount, int *secpkgcount, char ***pkglist, char ***secpkg
353 stderr_warning=1; 354 stderr_warning=1;
354 result = max_state(result, STATE_WARNING); 355 result = max_state(result, STATE_WARNING);
355 if(verbose){ 356 if(verbose){
356 for(i = 0; i < chld_err.lines; i++) { 357 for(size_t i = 0; i < chld_err.lines; i++) {
357 fprintf(stderr, "%s\n", chld_err.line[i]); 358 fprintf(stderr, "%s\n", chld_err.line[i]);
358 } 359 }
359 } 360 }
@@ -367,7 +368,7 @@ int run_upgrade(int *pkgcount, int *secpkgcount, char ***pkglist, char ***secpkg
367 368
368/* run an apt-get update (needs root) */ 369/* run an apt-get update (needs root) */
369int run_update(void){ 370int run_update(void){
370 int i=0, result=STATE_UNKNOWN; 371 int result=STATE_UNKNOWN;
371 struct output chld_out, chld_err; 372 struct output chld_out, chld_err;
372 char *cmdline; 373 char *cmdline;
373 374
@@ -385,7 +386,7 @@ int run_update(void){
385 } 386 }
386 387
387 if(verbose){ 388 if(verbose){
388 for(i = 0; i < chld_out.lines; i++) { 389 for(size_t i = 0; i < chld_out.lines; i++) {
389 printf("%s\n", chld_out.line[i]); 390 printf("%s\n", chld_out.line[i]);
390 } 391 }
391 } 392 }
@@ -395,7 +396,7 @@ int run_update(void){
395 stderr_warning=1; 396 stderr_warning=1;
396 result = max_state(result, STATE_WARNING); 397 result = max_state(result, STATE_WARNING);
397 if(verbose){ 398 if(verbose){
398 for(i = 0; i < chld_err.lines; i++) { 399 for(size_t i = 0; i < chld_err.lines; i++) {
399 fprintf(stderr, "%s\n", chld_err.line[i]); 400 fprintf(stderr, "%s\n", chld_err.line[i]);
400 } 401 }
401 } 402 }