Code reformatting

This commit is contained in:
Silvan Calarco 2021-02-14 22:26:37 +01:00
parent 9a546f52b9
commit 4f566ceec3

View File

@ -1183,20 +1183,12 @@ generateSourceHeaderList(struct configTag *ct, int mode, int incremental)
/* /*
* Reads all headers and generates a structure based on struct headerList */ * Reads all headers and generates a structure based on struct headerList */
int int addToHeaderList(struct configTag *ct,
addToHeaderList(struct configTag *ct,
const char *scanpath, /*int mode,*/ const char *scanpath, /*int mode,*/
const char *scantag, const char *scantag,
const char *altscanpath[ALT_REPS_MAX], const char *altscanpath[ALT_REPS_MAX],
const char *altscantag[ALT_REPS_MAX], const char *altscantag[ALT_REPS_MAX],
int arch) int arch) {
{
/*#headerList **headerlist,
# struct headerSourceList *headersourcelist,
# struct providedList **firstprovided,
*/
struct headerList *currheaderlist, *newheaderlist, *currbrother; struct headerList *currheaderlist, *newheaderlist, *currbrother;
struct providedList *provided; struct providedList *provided;
struct headerList ** newprovider; struct headerList ** newprovider;
@ -1224,7 +1216,6 @@ addToHeaderList(struct configTag *ct,
currheaderlist = ct->headerlist[arch]; currheaderlist = ct->headerlist[arch];
n = scansdir(scanpath, &namelist, rpmselector, scanrpmnamecmp); n = scansdir(scanpath, &namelist, rpmselector, scanrpmnamecmp);
if (n < 0) { if (n < 0) {
errstr = strerror(errno); errstr = strerror(errno);
logmsg(LOG_ERROR, "%s: cannot scan directory '%s' (%s)", scantag, scanpath, errstr); logmsg(LOG_ERROR, "%s: cannot scan directory '%s' (%s)", scantag, scanpath, errstr);
@ -1252,12 +1243,7 @@ addToHeaderList(struct configTag *ct,
} }
while (1) { while (1) {
/* if (cnt>=n) { break; }
for (i = 0; i < ALT_REPS_MAX; i++) {
if altcnt[i] >= altn[i]
}*/
/* check for duplicates in main repository */ /* check for duplicates in main repository */
if ((cnt < n - 1) && if ((cnt < n - 1) &&
(!rpmnamecmp(namelist[cnt]->d_name,namelist[cnt+1]->d_name,0))) { (!rpmnamecmp(namelist[cnt]->d_name,namelist[cnt+1]->d_name,0))) {
logmsg(LOG_WARNING, "%s: duplicated RPM package in %s repository (skipped)",namelist[cnt]->d_name, scantag); logmsg(LOG_WARNING, "%s: duplicated RPM package in %s repository (skipped)",namelist[cnt]->d_name, scantag);
@ -1306,7 +1292,6 @@ addToHeaderList(struct configTag *ct,
} }
} }
} }
/* break while loop when no more packages are found */ /* break while loop when no more packages are found */
if (currname[0] == '\0') { break; } if (currname[0] == '\0') { break; }
/* process package */ /* process package */
@ -1317,7 +1302,6 @@ addToHeaderList(struct configTag *ct,
logmsg(LOG_WARNING, logmsg(LOG_WARNING,
"%s: unable to read header (%s); skipping.",filename, errstr); "%s: unable to read header (%s); skipping.",filename, errstr);
} else { } else {
getPackageObsoletes(h, &obsoletename, &obsoleteflags, getPackageObsoletes(h, &obsoletename, &obsoleteflags,
&obsoleteversion, &obsoletecount); &obsoleteversion, &obsoletecount);
getPackageProvides(h, &providename, &provideflags, getPackageProvides(h, &providename, &provideflags,
@ -1372,9 +1356,7 @@ addToHeaderList(struct configTag *ct,
} }
currbrother->nextbrother = newheaderlist; currbrother->nextbrother = newheaderlist;
} }
newheaderlist->recursed = 0; newheaderlist->recursed = 0;
if (currheaderlist) { if (currheaderlist) {
currheaderlist->next = newheaderlist; currheaderlist->next = newheaderlist;
} }
@ -1384,12 +1366,9 @@ addToHeaderList(struct configTag *ct,
/* set first pointer of the list */ /* set first pointer of the list */
ct->headerlist[arch] = newheaderlist; ct->headerlist[arch] = newheaderlist;
} }
} else if (newheaderlist->sourcename) /* missing source header */ { } else if (newheaderlist->sourcename) /* missing source header */ {
if ((!newheaderlist->sourceheader) || if ((!newheaderlist->sourceheader) ||
(newheaderlist->sourceheader->altrepository) <= altrepository) (newheaderlist->sourceheader->altrepository) <= altrepository) {
{
logmsg(LOG_WARNING,"%s(%s,%s): missing SRPM %s-%s-%s; skipping.", logmsg(LOG_WARNING,"%s(%s,%s): missing SRPM %s-%s-%s; skipping.",
newheaderlist->name, newheaderlist->name,
ct->arch[arch], ct->arch[arch],
@ -1404,7 +1383,8 @@ addToHeaderList(struct configTag *ct,
newheaderlist->provided = malloc(sizeof(struct providedList*)*providecount); newheaderlist->provided = malloc(sizeof(struct providedList*)*providecount);
for (i=0; i < providecount; i++) { for (i=0; i < providecount; i++) {
provided = findOrCreateProvidedListEntry((struct providedList **) &(ct->providedlist_idx[arch]), provided = findOrCreateProvidedListEntry(
(struct providedList **) &(ct->providedlist_idx[arch]),
providename[i],1,arch); providename[i],1,arch);
newheaderlist->provided[i]=provided; newheaderlist->provided[i]=provided;
if (provided && (provided->numproviders == 0)) { if (provided && (provided->numproviders == 0)) {
@ -1431,24 +1411,19 @@ addToHeaderList(struct configTag *ct,
newversion[provided->numproviders-1] = strdup(provideversion[i]); newversion[provided->numproviders-1] = strdup(provideversion[i]);
free(provided->version); free(provided->version);
provided->version=newversion; provided->version=newversion;
} else { } else {
fprintf(stderr,"%s has %d providers but is ignored\n",provided->name,provided->numproviders); fprintf(stderr,"%s has %d providers but is ignored\n",provided->name,provided->numproviders);
} }
} }
newheaderlist->providename = providename; newheaderlist->providename = providename;
newheaderlist->provideflags = provideflags; newheaderlist->provideflags = provideflags;
newheaderlist->provideversion = provideversion; newheaderlist->provideversion = provideversion;
newheaderlist->providecount = providecount; newheaderlist->providecount = providecount;
newheaderlist->obsoletename = obsoletename; newheaderlist->obsoletename = obsoletename;
newheaderlist->obsoleteflags = obsoleteflags; newheaderlist->obsoleteflags = obsoleteflags;
newheaderlist->obsoleteversion = obsoleteversion; newheaderlist->obsoleteversion = obsoleteversion;
newheaderlist->obsoletecount = obsoletecount; newheaderlist->obsoletecount = obsoletecount;
newheaderlist->altrepository = altrepository; newheaderlist->altrepository = altrepository;
newheaderlist->require = malloc(requirecount * sizeof(struct Require *)); newheaderlist->require = malloc(requirecount * sizeof(struct Require *));
for (j=0; j < requirecount; j++) { for (j=0; j < requirecount; j++) {
newheaderlist->require[j] = malloc(sizeof(struct Require)); newheaderlist->require[j] = malloc(sizeof(struct Require));
@ -1458,7 +1433,6 @@ addToHeaderList(struct configTag *ct,
newheaderlist->require[j]->resolved = NULL; newheaderlist->require[j]->resolved = NULL;
} }
newheaderlist->requirecount = requirecount; newheaderlist->requirecount = requirecount;
newheaderlist->file = newheaderlist->file =
malloc(sizeof(struct fileTree*) * filenamecount); malloc(sizeof(struct fileTree*) * filenamecount);
newheaderlist->fileflags = newheaderlist->fileflags =
@ -1485,11 +1459,11 @@ addToHeaderList(struct configTag *ct,
if (newheaderlist->file[j]->provider[k] == newheaderlist) if (newheaderlist->file[j]->provider[k] == newheaderlist)
break; break;
} }
/* if not add to the list of providers */ /* if not add to the list of providers */
if (k == newheaderlist->file[j]->numproviders) { if (k == newheaderlist->file[j]->numproviders) {
newheaderlist->file[j]->numproviders++; newheaderlist->file[j]->numproviders++;
newprovider=malloc(sizeof(struct headerList*)*newheaderlist->file[j]->numproviders); newprovider=malloc(
sizeof(struct headerList*)*newheaderlist->file[j]->numproviders);
for (k = 0; k < newheaderlist->file[j]->numproviders-1; k++) { for (k = 0; k < newheaderlist->file[j]->numproviders-1; k++) {
newprovider[k]=newheaderlist->file[j]->provider[k]; newprovider[k]=newheaderlist->file[j]->provider[k];
} }
@ -1502,8 +1476,8 @@ addToHeaderList(struct configTag *ct,
newheaderlist->filenamecount = filenamecount; newheaderlist->filenamecount = filenamecount;
(void) headerFree(h); (void) headerFree(h);
} // if getHeader() } // if getHeader()
if (altrepository > 0) { if (altrepository > 0)
free(altnamelist[altrepository-1][altcnt[altrepository-1]-1]); } free(altnamelist[altrepository-1][altcnt[altrepository-1]-1]);
else free(namelist[cnt-1]); else free(namelist[cnt-1]);
} // main while } // main while
#if RPM_VERSION >= 0x050000 #if RPM_VERSION >= 0x050000
@ -1552,6 +1526,5 @@ generateHeaderList(struct configTag* ct, int arch, int incremental)
logmsg(LOG_ERROR,"Error scanning RPMs repository"); logmsg(LOG_ERROR,"Error scanning RPMs repository");
return 1; return 1;
} }
return 0; return 0;
} }