Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ecmp.c #119

Merged
merged 1 commit into from
Oct 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions formats/ecmp/ecmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
}section;


unsigned int getsections(char* path,section*** sectionq);

Check warning on line 27 in formats/ecmp/ecmp.c

View workflow job for this annotation

GitHub Actions / c-linter

formats/ecmp/ecmp.c:27:14 [readability-inconsistent-declaration-parameter-name]

function 'getsections' has a definition with different parameter names

unsigned int parseinfo(char* s, struct package* dest);
unsigned int parseraw(char* s, char** dest);
unsigned int parsenl(char* s,char*** dest);

hashtable* hm;

Check warning on line 33 in formats/ecmp/ecmp.c

View workflow job for this annotation

GitHub Actions / c-linter

formats/ecmp/ecmp.c:33:12 [cppcoreguidelines-avoid-non-const-global-variables]

variable 'hm' is non-const and globally accessible, consider making it const

Check warning on line 33 in formats/ecmp/ecmp.c

View workflow job for this annotation

GitHub Actions / c-linter

formats/ecmp/ecmp.c:33:12 [cppcoreguidelines-avoid-non-const-global-variables]

variable 'hm' provides global access to a non-const object; consider making the pointed-to data 'const'
hashtable* infohm;

Check warning on line 34 in formats/ecmp/ecmp.c

View workflow job for this annotation

GitHub Actions / c-linter

formats/ecmp/ecmp.c:34:12 [cppcoreguidelines-avoid-non-const-global-variables]

variable 'infohm' is non-const and globally accessible, consider making it const

Check warning on line 34 in formats/ecmp/ecmp.c

View workflow job for this annotation

GitHub Actions / c-linter

formats/ecmp/ecmp.c:34:12 [cppcoreguidelines-avoid-non-const-global-variables]

variable 'infohm' provides global access to a non-const object; consider making the pointed-to data 'const'

#ifdef STATIC
int open_ecmp(char* path,struct package* pkg)
Expand Down Expand Up @@ -96,9 +96,9 @@



unsigned int (*parser)(char* s,void* dest);

Check warning on line 99 in formats/ecmp/ecmp.c

View workflow job for this annotation

GitHub Actions / c-linter

formats/ecmp/ecmp.c:99:17 [cppcoreguidelines-init-variables]

variable 'parser' is not initialized

section** sections;

Check warning on line 101 in formats/ecmp/ecmp.c

View workflow job for this annotation

GitHub Actions / c-linter

formats/ecmp/ecmp.c:101:12 [cppcoreguidelines-init-variables]

variable 'sections' is not initialized
uint count = getsections(path,&sections);

for (unsigned int i = 0; i < count; i++) {
Expand Down Expand Up @@ -141,7 +141,7 @@

unsigned int parsenl(char* s,char*** dest)
{
char* str;

Check warning on line 144 in formats/ecmp/ecmp.c

View workflow job for this annotation

GitHub Actions / c-linter

formats/ecmp/ecmp.c:144:8 [cppcoreguidelines-init-variables]

variable 'str' is not initialized
// the parseraw below is useless but i'll keep since in case
parseraw(s,&str);
return splita(str,'\n',dest);
Expand All @@ -157,22 +157,22 @@
return strlen(s);
}

unsigned int parseinfo(char *s, struct package* dest)
{
unsigned int parseinfo(char *s, struct package* dest) {
(void)dest;
char* p = s;
while (*p != '\0') {
if (*p == ' ') {
unsigned int index = p - s;
// ^ this could be a long, but it doesn't need to be 64 bits
dbg(3, "Removing space '%c']'%c'['%c' at %p (index=%d)", *(p - 1), *p, *(p + 1), p, index);
popchar(s, index);

Check warning on line 168 in formats/ecmp/ecmp.c

View workflow job for this annotation

GitHub Actions / c-linter

formats/ecmp/ecmp.c:168:13 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]

Call to function 'memmove' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'memmove_s' in case of C11
p--;
}
p++;
}

// split with nl
char** nlist;

Check warning on line 175 in formats/ecmp/ecmp.c

View workflow job for this annotation

GitHub Actions / c-linter

formats/ecmp/ecmp.c:175:12 [cppcoreguidelines-init-variables]

variable 'nlist' is not initialized
int count = parsenl(s, &nlist);

dbg(3, "count : %d", count);
Expand Down Expand Up @@ -214,9 +214,11 @@
ssize_t read;
*sections = calloc(16,sizeof(section));
unsigned int sectionsalloc = 256;
(void)sectionsalloc;
unsigned int sectionscount = 0;

section* current = NULL;
(void)current;
unsigned int alloc = 0;

while ((read = getline(&line,&len,fp)) != EOF) {
Expand Down Expand Up @@ -319,4 +321,3 @@
return 0;

}

Loading