Bug Summary

File:rpm2cpio.c
Warning:line 59, column 2
Value stored to 'ts' is never read

Annotated Source Code

1/* rpmarchive: spit out the main archive portion of a package */
2
3#include "system.h"
4
5#include <rpm/rpmlib.h> /* rpmReadPackageFile .. */
6#include <rpm/rpmtag.h>
7#include <rpm/rpmio.h>
8#include <rpm/rpmpgp.h>
9
10#include <rpm/rpmts.h>
11#include <unistd.h>
12
13#include "debug.h"
14
15int main(int argc, char *argv[])
16{
17 FD_t fdi, fdo;
18 Header h;
19 char * rpmio_flags = NULL((void*)0);
20 int rc;
21 off_t payload_size;
22 FD_t gzdi;
23
24 xsetprogname(argv[0]); /* Portability call -- see system.h */
25
26 rpmReadConfigFiles(NULL((void*)0), NULL((void*)0));
27 if (argc == 1)
28 fdi = fdDup(STDIN_FILENO0);
29 else {
30 if (rstreq(argv[1], "-h") || rstreq(argv[1], "--help")) {
31 fprintf(stderrstderr, "Usage: rpm2cpio file.rpm\n");
32 exit(EXIT_FAILURE1);
33 }
34 fdi = Fopen(argv[1], "r.ufdio");
35 }
36
37 if (Ferror(fdi)) {
38 fprintf(stderrstderr, "%s: %s: %s\n", argv[0],
39 (argc == 1 ? "<stdin>" : argv[1]), Fstrerror(fdi));
40 exit(EXIT_FAILURE1);
41 }
42 if (isatty(STDOUT_FILENO1)) {
43 fprintf(stderrstderr, "Error: refusing to output cpio data to a terminal.\n");
44 exit(EXIT_FAILURE1);
45 }
46 fdo = fdDup(STDOUT_FILENO1);
47
48 { rpmts ts = rpmtsCreate();
49 rpmVSFlags vsflags = 0;
50
51 /* XXX retain the ageless behavior of rpm2cpio */
52 vsflags |= _RPMVSF_NODIGESTS( RPMVSF_NOSHA1HEADER | RPMVSF_NOSHA256HEADER | RPMVSF_NOPAYLOAD
| RPMVSF_NOMD5 )
;
53 vsflags |= _RPMVSF_NOSIGNATURES( RPMVSF_NODSAHEADER | RPMVSF_NORSAHEADER | RPMVSF_NODSA | RPMVSF_NORSA
)
;
54 vsflags |= RPMVSF_NOHDRCHK;
55 (void) rpmtsSetVSFlags(ts, vsflags);
56
57 rc = rpmReadPackageFile(ts, fdi, "rpm2cpio", &h);
58
59 ts = rpmtsFree(ts);
Value stored to 'ts' is never read
60 }
61
62 switch (rc) {
63 case RPMRC_OK:
64 case RPMRC_NOKEY:
65 case RPMRC_NOTTRUSTED:
66 break;
67 case RPMRC_NOTFOUND:
68 fprintf(stderrstderr, _("argument is not an RPM package\n")dcgettext ("rpm", "argument is not an RPM package\n", 5));
69 exit(EXIT_FAILURE1);
70 break;
71 case RPMRC_FAIL:
72 default:
73 fprintf(stderrstderr, _("error reading header from package\n")dcgettext ("rpm", "error reading header from package\n", 5));
74 exit(EXIT_FAILURE1);
75 break;
76 }
77
78 /* Retrieve payload size and compression type. */
79 { const char *compr = headerGetString(h, RPMTAG_PAYLOADCOMPRESSOR);
80 rpmio_flags = rstrscat(NULL((void*)0), "r.", compr ? compr : "gzip", NULL((void*)0));
81 payload_size = headerGetNumber(h, RPMTAG_LONGARCHIVESIZE);
82 }
83
84 gzdi = Fdopen(fdi, rpmio_flags); /* XXX gzdi == fdi */
85 free(rpmio_flags);
86
87 if (gzdi == NULL((void*)0)) {
88 fprintf(stderrstderr, _("cannot re-open payload: %s\n")dcgettext ("rpm", "cannot re-open payload: %s\n", 5), Fstrerror(gzdi));
89 exit(EXIT_FAILURE1);
90 }
91
92 rc = (ufdCopy(gzdi, fdo) == payload_size) ? EXIT_SUCCESS0 : EXIT_FAILURE1;
93
94 Fclose(fdo);
95
96 Fclose(gzdi); /* XXX gzdi == fdi */
97
98 return rc;
99}