Skip to content

Commit

Permalink
Merge pull request #120 from mephistolist/main
Browse files Browse the repository at this point in the history
Fixing New Warnings.
  • Loading branch information
AleksArt000 authored Oct 29, 2024
2 parents 9117bc9 + d82467f commit 3a9d846
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
9 changes: 4 additions & 5 deletions src/download.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@
#include "libspm.h"
#include "cutils.h"

int download(char* url, FILE* fp)
{
int download(char* url, FILE* fp) {
CURL *curl = curl_easy_init();
if(curl)
{
if(curl) {
CURLcode res;
(void) res;
curl_easy_setopt(curl, CURLOPT_USERAGENT, "CCCP/1.0 (https://www.sovietlinux.org/)");
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
curl_easy_setopt(curl, CURLOPT_URL, url);
Expand All @@ -26,4 +25,4 @@ int download(char* url, FILE* fp)
curl_easy_cleanup(curl);
}
return 0;
}
}
14 changes: 9 additions & 5 deletions src/make.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*/
int make(char* package_dir, struct package* pkg) {

Check warning on line 26 in src/make.c

View workflow job for this annotation

GitHub Actions / c-linter

src/make.c:26:5 [readability-function-cognitive-complexity]

function 'make' has cognitive complexity of 37 (threshold 25)
char* build_dir = getenv("SOVIET_BUILD_DIR");
(void)build_dir;
char* make_dir = getenv("SOVIET_MAKE_DIR");

char* cmd_params;

Check warning on line 31 in src/make.c

View workflow job for this annotation

GitHub Actions / c-linter

src/make.c:31:11 [cppcoreguidelines-init-variables]

variable 'cmd_params' is not initialized
Expand All @@ -44,7 +45,9 @@ int make(char* package_dir, struct package* pkg) {
for (int i = 0; i < pkg->filesCount; i++)
{
int download_attempts = 3;
int download_success = 0;
(void)download_attempts;
int download_success = 0;
(void)download_success;

struct stat st_source = {0};
struct stat st_source_loc = {0};
Expand Down Expand Up @@ -107,10 +110,11 @@ int make(char* package_dir, struct package* pkg) {

SHA256((unsigned char*) buffer, size, hash);

if (hash == NULL) {
/* This caused and warning and functionally does nothing. Here hash is an array of unsigned char, but arrays in C are not pointers that can be NULL. This should probably be done with fread or fopen instead. Commenting out for now to silence the warning*/
/*if (hash == NULL) {
msg(FATAL, "Could not verify the file's hash");
return -1;
}
}*/

dbg(1, "Hash is %s", file_sha256);
for(int k = 0; k < SHA256_DIGEST_LENGTH; k++) {
Expand All @@ -136,8 +140,8 @@ int make(char* package_dir, struct package* pkg) {
dbg(1, "Loading form %s", source_location);
loadFile(source_file_location, location);
}
free(files);

free(files);
free(location);
free(source_location);
free(source_file_location);
Expand Down

0 comments on commit 3a9d846

Please sign in to comment.