Optimization warning fixes
This commit is contained in:
parent
b14c9271cf
commit
61352c7c3e
@ -44,7 +44,7 @@ target_link_libraries(distromatic
|
|||||||
${LIBIBERTY}
|
${LIBIBERTY}
|
||||||
)
|
)
|
||||||
target_include_directories(distromatic PUBLIC ${RPM_INCLUDE_DIRS})
|
target_include_directories(distromatic PUBLIC ${RPM_INCLUDE_DIRS})
|
||||||
target_compile_options(distromatic PUBLIC -g -Wall -std=gnu11 -pedantic ${RPM_CFLAGS_OTHER})
|
target_compile_options(distromatic PUBLIC -O2 -g -Wall -std=gnu11 -pedantic ${RPM_CFLAGS_OTHER})
|
||||||
|
|
||||||
add_executable(distroquery
|
add_executable(distroquery
|
||||||
distroquery.c
|
distroquery.c
|
||||||
|
@ -142,7 +142,7 @@ getPackageChangelog(Header h, struct headerSourceList* headersource)
|
|||||||
|
|
||||||
newchangelog->time = changelogtime[i];
|
newchangelog->time = changelogtime[i];
|
||||||
|
|
||||||
strncpy(changelogname, changelogrelease[i], 255);
|
strcpy(changelogname, changelogrelease[i]);
|
||||||
endp = strchr(changelogname, '>');
|
endp = strchr(changelogname, '>');
|
||||||
if (endp) {
|
if (endp) {
|
||||||
endp[1] = '\0';
|
endp[1] = '\0';
|
||||||
|
@ -164,7 +164,7 @@ struct configTag* read_configuration(const char *confFile)
|
|||||||
newconfigtag->configdefaults = &configdefaults;
|
newconfigtag->configdefaults = &configdefaults;
|
||||||
|
|
||||||
if (configdefaults.html_basedir) {
|
if (configdefaults.html_basedir) {
|
||||||
strncpy(buf, configdefaults.html_basedir, PATH_MAX);
|
strcpy(buf, configdefaults.html_basedir);
|
||||||
strncat(buf, newconfigtag->tag, sizeof(buf) - strlen(buf));
|
strncat(buf, newconfigtag->tag, sizeof(buf) - strlen(buf));
|
||||||
strncat(buf, "/", sizeof(buf) - strlen(buf));
|
strncat(buf, "/", sizeof(buf) - strlen(buf));
|
||||||
newconfigtag->html_dir = (char *) strdup(buf);
|
newconfigtag->html_dir = (char *) strdup(buf);
|
||||||
@ -318,7 +318,7 @@ struct configTag* read_configuration(const char *confFile)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!currconfigtag->repository_source_dir) {
|
if (!currconfigtag->repository_source_dir) {
|
||||||
strncpy(buf, currconfigtag->repository_dir, PATH_MAX);
|
strcpy(buf, currconfigtag->repository_dir);
|
||||||
strncat(buf, "/SRPMS.base/", sizeof(buf) - strlen(buf));
|
strncat(buf, "/SRPMS.base/", sizeof(buf) - strlen(buf));
|
||||||
currconfigtag->repository_source_dir =
|
currconfigtag->repository_source_dir =
|
||||||
(char *) strdup(buf);
|
(char *) strdup(buf);
|
||||||
@ -426,7 +426,7 @@ void logmsg(int level, const char *msg, ...) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ((level == LOG_WARNING) || (level == LOG_ERROR)) {
|
if ((level == LOG_WARNING) || (level == LOG_ERROR)) {
|
||||||
strncpy(oldmsg[curroldmsg++],newmsg,256);
|
strncpy(oldmsg[curroldmsg++],newmsg,PATH_MAX);
|
||||||
if (curroldmsg >= 20) curroldmsg = 0;
|
if (curroldmsg >= 20) curroldmsg = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
|
||||||
#define HDSIZE 16
|
#define HDSIZE 16
|
||||||
#define SSSIZE 16
|
#define SSSIZE 24
|
||||||
|
|
||||||
typedef char humanDate[HDSIZE];
|
typedef char humanDate[HDSIZE];
|
||||||
typedef char sizeString[SSSIZE];
|
typedef char sizeString[SSSIZE];
|
||||||
|
@ -26,11 +26,10 @@ int cleanHTMLFiles(struct configTag *ct);
|
|||||||
int generateHTMLFiles(struct configTag *configtag,int arch);
|
int generateHTMLFiles(struct configTag *configtag,int arch);
|
||||||
int generateHTML_SRPMSFiles(struct configTag *configtag);
|
int generateHTML_SRPMSFiles(struct configTag *configtag);
|
||||||
int generateHTMLMainIndex(struct configTag *configtag);
|
int generateHTMLMainIndex(struct configTag *configtag);
|
||||||
char *groupdirname(char *group,char *dest,unsigned int max);
|
|
||||||
int write_RPM_HTML(struct configTag *ct,FILE *fout, struct headerList *currheaderlist);
|
int write_RPM_HTML(struct configTag *ct,FILE *fout, struct headerList *currheaderlist);
|
||||||
int print_contentslist(struct configTag *ct, int arch);
|
int print_contentslist(struct configTag *ct, int arch);
|
||||||
int print_datatables(struct configTag *ct, int arch);
|
int print_datatables(struct configTag *ct, int arch);
|
||||||
char *ftname(struct fileTree* ft, char* buf, unsigned int bufsize);
|
char *ftname(struct fileTree* ft, char* buf);
|
||||||
void print_contents_subtree(FILE *f,
|
void print_contents_subtree(FILE *f,
|
||||||
struct fileTree* ft,
|
struct fileTree* ft,
|
||||||
struct configTag* ct,
|
struct configTag* ct,
|
||||||
|
@ -41,13 +41,13 @@
|
|||||||
#define HTMLOLDSTATS_NUM 400
|
#define HTMLOLDSTATS_NUM 400
|
||||||
#define RSSSTATS_NUM 20
|
#define RSSSTATS_NUM 20
|
||||||
|
|
||||||
char *groupdirname(char *group,char *dest,unsigned int max)
|
char *groupdirname(char *group,char *dest)
|
||||||
{
|
{
|
||||||
strncpy(dest,group,max);
|
strcpy(dest,group);
|
||||||
|
|
||||||
unsigned int i=0;
|
unsigned int i=0;
|
||||||
|
|
||||||
while (dest[i] && i<max) {
|
while (dest[i] && i<PATH_MAX) {
|
||||||
switch (dest[i]) {
|
switch (dest[i]) {
|
||||||
case '/': dest[i]=':'; break;
|
case '/': dest[i]=':'; break;
|
||||||
case ' ': dest[i]='_'; break;
|
case ' ': dest[i]='_'; break;
|
||||||
@ -439,9 +439,9 @@ generateStats(struct configTag *configtag,int arch)
|
|||||||
|
|
||||||
if (pkgnum==0) {
|
if (pkgnum==0) {
|
||||||
|
|
||||||
snprintf(outfile, PATH_MAX, "%sgroups/%s",
|
sprintf(outfile, "%sgroups/%s",
|
||||||
configtag->html_dir,
|
configtag->html_dir,
|
||||||
groupdirname(configtag->stats.headersourcelistvec[i]->group,buffer,PATH_MAX));
|
groupdirname(configtag->stats.headersourcelistvec[i]->group,buffer));
|
||||||
|
|
||||||
if (stat(outfile,&buf)) {
|
if (stat(outfile,&buf)) {
|
||||||
if (mkdir(outfile,S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) {
|
if (mkdir(outfile,S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)) {
|
||||||
@ -484,7 +484,7 @@ generateStats(struct configTag *configtag,int arch)
|
|||||||
"<a href=\"%stag=%s&group=%s\">%s <b>(%d)</b></a><br>\n",
|
"<a href=\"%stag=%s&group=%s\">%s <b>(%d)</b></a><br>\n",
|
||||||
configtag->configdefaults->url_prefix,
|
configtag->configdefaults->url_prefix,
|
||||||
configtag->tag,
|
configtag->tag,
|
||||||
groupdirname(configtag->stats.headersourcelistvec[i-1]->group,buffer,PATH_MAX),
|
groupdirname(configtag->stats.headersourcelistvec[i-1]->group,buffer),
|
||||||
(configtag->stats.headersourcelistvec)[i-1]->group,
|
(configtag->stats.headersourcelistvec)[i-1]->group,
|
||||||
pkgnum);
|
pkgnum);
|
||||||
pkgnum=0;
|
pkgnum=0;
|
||||||
@ -497,7 +497,7 @@ generateStats(struct configTag *configtag,int arch)
|
|||||||
fclose(groupout);
|
fclose(groupout);
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(outfile, configtag->html_dir, PATH_MAX);
|
strcpy(outfile, configtag->html_dir);
|
||||||
strncat(outfile, "_recent.inc", sizeof(outfile) - strlen(outfile));
|
strncat(outfile, "_recent.inc", sizeof(outfile) - strlen(outfile));
|
||||||
if ((htmlout = fopen(outfile, "w")) == NULL) {
|
if ((htmlout = fopen(outfile, "w")) == NULL) {
|
||||||
perror(outfile);
|
perror(outfile);
|
||||||
@ -513,7 +513,7 @@ generateStats(struct configTag *configtag,int arch)
|
|||||||
fprintf(htmlout, "Recent builds:<br>\n");
|
fprintf(htmlout, "Recent builds:<br>\n");
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
strncpy(outfile, configtag->html_dir, PATH_MAX);
|
strcpy(outfile, configtag->html_dir);
|
||||||
strncat(outfile, "_oldest.inc", sizeof(outfile) - strlen(outfile));
|
strncat(outfile, "_oldest.inc", sizeof(outfile) - strlen(outfile));
|
||||||
if ((htmloldout = fopen(outfile, "w")) == NULL) {
|
if ((htmloldout = fopen(outfile, "w")) == NULL) {
|
||||||
perror(outfile);
|
perror(outfile);
|
||||||
@ -524,7 +524,7 @@ generateStats(struct configTag *configtag,int arch)
|
|||||||
fprintf(htmloldout, "Oldest builds:<br>\n");
|
fprintf(htmloldout, "Oldest builds:<br>\n");
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
strncpy(rssfile, configtag->html_dir, PATH_MAX);
|
strcpy(rssfile, configtag->html_dir);
|
||||||
strncat(rssfile, "recent.rss", sizeof(rssfile) - strlen(rssfile));
|
strncat(rssfile, "recent.rss", sizeof(rssfile) - strlen(rssfile));
|
||||||
if ((rssout = fopen(rssfile, "w")) == NULL) {
|
if ((rssout = fopen(rssfile, "w")) == NULL) {
|
||||||
perror(rssfile);
|
perror(rssfile);
|
||||||
@ -651,7 +651,7 @@ generateStats(struct configTag *configtag,int arch)
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
/* remove final slashes from download_prefix as required by apt */
|
/* remove final slashes from download_prefix as required by apt */
|
||||||
strncpy(buffer, configtag->download_dir, PATH_MAX);
|
strcpy(buffer, configtag->download_dir);
|
||||||
|
|
||||||
i=strlen(buffer);
|
i=strlen(buffer);
|
||||||
while ((i > 0) && (buffer[i-1] == '/' )) {
|
while ((i > 0) && (buffer[i-1] == '/' )) {
|
||||||
@ -690,7 +690,7 @@ generateStats(struct configTag *configtag,int arch)
|
|||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
/* remove final slashes from download_prefix as required by apt */
|
/* remove final slashes from download_prefix as required by apt */
|
||||||
strncpy(buffer, configtag->download_dir, PATH_MAX);
|
strcpy(buffer, configtag->download_dir);
|
||||||
|
|
||||||
i=strlen(buffer);
|
i=strlen(buffer);
|
||||||
while ((i > 0) && (buffer[i-1] == '/' )) {
|
while ((i > 0) && (buffer[i-1] == '/' )) {
|
||||||
@ -753,7 +753,7 @@ generateHTMLMainIndex(struct configTag *configtag)
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(indexfile, configtag->configdefaults->html_basedir, PATH_MAX);
|
strcpy(indexfile, configtag->configdefaults->html_basedir);
|
||||||
strncat(indexfile, "_index.inc", sizeof(indexfile) - strlen(indexfile));
|
strncat(indexfile, "_index.inc", sizeof(indexfile) - strlen(indexfile));
|
||||||
|
|
||||||
if ((fout = fopen(indexfile, "w")) == NULL) {
|
if ((fout = fopen(indexfile, "w")) == NULL) {
|
||||||
@ -789,7 +789,7 @@ generateHTMLMainIndex(struct configTag *configtag)
|
|||||||
configtag->description);
|
configtag->description);
|
||||||
|
|
||||||
/* remove final slashes from download_prefix as required by apt */
|
/* remove final slashes from download_prefix as required by apt */
|
||||||
strncpy(buffer, configtag->download_dir, PATH_MAX);
|
strcpy(buffer, configtag->download_dir);
|
||||||
i=strlen(buffer);
|
i=strlen(buffer);
|
||||||
while ((i > 0) && (buffer[i-1] == '/' )) {
|
while ((i > 0) && (buffer[i-1] == '/' )) {
|
||||||
buffer[i-1]='\0';
|
buffer[i-1]='\0';
|
||||||
@ -987,7 +987,7 @@ generateHTML_SRPMSFiles(struct configTag *configtag)
|
|||||||
"<tr><td>Group:</td><td><a href=\"%stag=%s&group=%s\">%s</a></td></tr>\n",
|
"<tr><td>Group:</td><td><a href=\"%stag=%s&group=%s\">%s</a></td></tr>\n",
|
||||||
configtag->configdefaults->url_prefix,
|
configtag->configdefaults->url_prefix,
|
||||||
configtag->tag,
|
configtag->tag,
|
||||||
groupdirname(currheadersourcelist->group, buffer2, PATH_MAX),
|
groupdirname(currheadersourcelist->group, buffer2),
|
||||||
htmlclean(currheadersourcelist->group,buffer,PATH_MAX));
|
htmlclean(currheadersourcelist->group,buffer,PATH_MAX));
|
||||||
|
|
||||||
fprintf(fout,
|
fprintf(fout,
|
||||||
@ -1096,7 +1096,7 @@ generateHTML_SRPMSFiles(struct configTag *configtag)
|
|||||||
fprintf(findexout[idx],"</td><td><b>%s</b>: <i>%s</i>",currheadersourcelist->name,htmlclean(currheadersourcelist->summary,buffer,PATH_MAX));
|
fprintf(findexout[idx],"</td><td><b>%s</b>: <i>%s</i>",currheadersourcelist->name,htmlclean(currheadersourcelist->summary,buffer,PATH_MAX));
|
||||||
st=strstr(currheadersourcelist->url,"://");
|
st=strstr(currheadersourcelist->url,"://");
|
||||||
if (st) {
|
if (st) {
|
||||||
strncpy(buffer,st+3,PATH_MAX);
|
strcpy(buffer,st+3);
|
||||||
st=strchr(buffer,'/');
|
st=strchr(buffer,'/');
|
||||||
if (st) st[0]='\0';
|
if (st) st[0]='\0';
|
||||||
fprintf(findexout[idx],
|
fprintf(findexout[idx],
|
||||||
@ -1346,7 +1346,7 @@ cleanHTMLFiles(struct configTag *ct)
|
|||||||
while (currheadersourcelist) {
|
while (currheadersourcelist) {
|
||||||
snprintf(dir, PATH_MAX, "%sgroups/%s",
|
snprintf(dir, PATH_MAX, "%sgroups/%s",
|
||||||
ct->html_dir,
|
ct->html_dir,
|
||||||
groupdirname(currheadersourcelist->group,uf,PATH_MAX));
|
groupdirname(currheadersourcelist->group,uf));
|
||||||
|
|
||||||
if (!stat(dir,&buf)) {
|
if (!stat(dir,&buf)) {
|
||||||
logmsg(LOG_DEBUG,"removing directory %s",dir);
|
logmsg(LOG_DEBUG,"removing directory %s",dir);
|
||||||
@ -1363,7 +1363,7 @@ cleanHTMLFiles(struct configTag *ct)
|
|||||||
/* legacy: clean old group dirs */
|
/* legacy: clean old group dirs */
|
||||||
snprintf(dir, PATH_MAX, "%s%s",
|
snprintf(dir, PATH_MAX, "%s%s",
|
||||||
ct->html_dir,
|
ct->html_dir,
|
||||||
groupdirname(currheadersourcelist->group,uf,PATH_MAX));
|
groupdirname(currheadersourcelist->group,uf));
|
||||||
|
|
||||||
if (!stat(dir,&buf)) {
|
if (!stat(dir,&buf)) {
|
||||||
logmsg(LOG_DEBUG,"removing legacy directory %s",dir);
|
logmsg(LOG_DEBUG,"removing legacy directory %s",dir);
|
||||||
@ -1696,8 +1696,7 @@ generateHTMLFiles(struct configTag *ct, int arch)
|
|||||||
fprintf(fout,
|
fprintf(fout,
|
||||||
"<tr><td>Filenames:</td><td><font size=\"-1\">");
|
"<tr><td>Filenames:</td><td><font size=\"-1\">");
|
||||||
for (i = 0; i < currheaderlist->filenamecount; i++) {
|
for (i = 0; i < currheaderlist->filenamecount; i++) {
|
||||||
ftname((currheaderlist->file)[i],
|
ftname((currheaderlist->file)[i], buffer);
|
||||||
buffer, PATH_MAX);
|
|
||||||
|
|
||||||
fprintf(fout, "/%s ",buffer);
|
fprintf(fout, "/%s ",buffer);
|
||||||
}
|
}
|
||||||
@ -1710,19 +1709,19 @@ generateHTMLFiles(struct configTag *ct, int arch)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *ftname(struct fileTree* ft, char* buf, unsigned int bufsize) {
|
char *ftname(struct fileTree* ft, char* buf) {
|
||||||
|
|
||||||
buf[0]='\0';
|
buf[0]='\0';
|
||||||
int l;
|
int l;
|
||||||
|
|
||||||
if (ft) {
|
if (ft) {
|
||||||
strncpy(buf,ft->name,bufsize);
|
strcpy(buf,ft->name);
|
||||||
ft=ft->parent;
|
ft=ft->parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (ft) {
|
while (ft) {
|
||||||
l=strlen(ft->name);
|
l=strlen(ft->name);
|
||||||
if (strlen(buf)+l+1 <= bufsize) {
|
if (strlen(buf)+l+1 <= PATH_MAX) {
|
||||||
memmove(buf+l+1,buf,strlen(buf)+1);
|
memmove(buf+l+1,buf,strlen(buf)+1);
|
||||||
memcpy(buf,ft->name,l);
|
memcpy(buf,ft->name,l);
|
||||||
buf[l]='/';
|
buf[l]='/';
|
||||||
@ -1747,7 +1746,7 @@ void print_contents_subtree(FILE *f,
|
|||||||
((ft->provider[k]) &&
|
((ft->provider[k]) &&
|
||||||
(ft->provider[k]->sourceheader) &&
|
(ft->provider[k]->sourceheader) &&
|
||||||
(ft->provider[k]->altrepository == ct->repository_level))) {
|
(ft->provider[k]->altrepository == ct->repository_level))) {
|
||||||
ftname(ft,buf,bufsize);
|
ftname(ft,buf);
|
||||||
if ((j=strlen(buf)) < 60) {
|
if ((j=strlen(buf)) < 60) {
|
||||||
for (i=(60-j)/8; i>0; i--) strncat(buf, "\t", bufsize - strlen(buf));
|
for (i=(60-j)/8; i>0; i--) strncat(buf, "\t", bufsize - strlen(buf));
|
||||||
while (strlen(buf) < 60) strncat(buf, " ", bufsize - strlen(buf));
|
while (strlen(buf) < 60) strncat(buf, " ", bufsize - strlen(buf));
|
||||||
|
@ -147,7 +147,7 @@ headerGetStringEntry(Header h, const int tag)
|
|||||||
char **
|
char **
|
||||||
headerGetStringArrayEntry(Header h, const int tag, int* count)
|
headerGetStringArrayEntry(Header h, const int tag, int* count)
|
||||||
{
|
{
|
||||||
char **st;
|
char **st = NULL;
|
||||||
|
|
||||||
#if RPM_VERSION_MAJOR >= 0x050000
|
#if RPM_VERSION_MAJOR >= 0x050000
|
||||||
HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he));
|
HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he));
|
||||||
@ -158,7 +158,6 @@ headerGetStringArrayEntry(Header h, const int tag, int* count)
|
|||||||
st = dupnargv(he->p.ptr, he->c);
|
st = dupnargv(he->p.ptr, he->c);
|
||||||
} else {
|
} else {
|
||||||
*count = 0;
|
*count = 0;
|
||||||
st = NULL;
|
|
||||||
}
|
}
|
||||||
he->p.ptr = _free(he->p.ptr);
|
he->p.ptr = _free(he->p.ptr);
|
||||||
#else
|
#else
|
||||||
|
Loading…
Reference in New Issue
Block a user