diff options
author | Peter Eisentraut | 2011-09-11 18:54:32 +0000 |
---|---|---|
committer | Peter Eisentraut | 2011-09-11 18:54:32 +0000 |
commit | 1b81c2fe6ee2b26d37610c3d381a87fa17af0a7c (patch) | |
tree | 09075f19d47fd81df20beb96e27e0f21ad2a0729 /src/bin | |
parent | 02bca4f35164dd1873eab9b8e6167e42a79157c4 (diff) |
Remove many -Wcast-qual warnings
This addresses only those cases that are easy to fix by adding or
moving a const qualifier or removing an unnecessary cast. There are
many more complicated cases remaining.
Diffstat (limited to 'src/bin')
-rw-r--r-- | src/bin/pg_dump/common.c | 4 | ||||
-rw-r--r-- | src/bin/pg_dump/pg_backup_archiver.c | 4 | ||||
-rw-r--r-- | src/bin/pg_dump/pg_backup_files.c | 2 | ||||
-rw-r--r-- | src/bin/pg_dump/pg_backup_tar.c | 6 | ||||
-rw-r--r-- | src/bin/pg_dump/pg_dump_sort.c | 12 | ||||
-rw-r--r-- | src/bin/psql/mbprint.c | 4 | ||||
-rw-r--r-- | src/bin/psql/mbprint.h | 4 | ||||
-rw-r--r-- | src/bin/psql/print.c | 20 |
8 files changed, 28 insertions, 28 deletions
diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index a631f64c36f..7eff05fcedf 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -650,8 +650,8 @@ buildIndexArray(void *objArray, int numObjs, Size objSize) static int DOCatalogIdCompare(const void *p1, const void *p2) { - DumpableObject *obj1 = *(DumpableObject **) p1; - DumpableObject *obj2 = *(DumpableObject **) p2; + const DumpableObject *obj1 = *(DumpableObject * const *) p1; + const DumpableObject *obj2 = *(DumpableObject * const *) p2; int cmpval; /* diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c index 1611551638b..f47af264cba 100644 --- a/src/bin/pg_dump/pg_backup_archiver.c +++ b/src/bin/pg_dump/pg_backup_archiver.c @@ -1393,7 +1393,7 @@ ahwrite(const void *ptr, size_t size, size_t nmemb, ArchiveHandle *AH) } else if (AH->gzOut) { - res = GZWRITE((void *) ptr, size, nmemb, AH->OF); + res = GZWRITE(ptr, size, nmemb, AH->OF); if (res != (nmemb * size)) die_horribly(AH, modulename, "could not write to output file: %s\n", strerror(errno)); return res; @@ -1416,7 +1416,7 @@ ahwrite(const void *ptr, size_t size, size_t nmemb, ArchiveHandle *AH) return ExecuteSqlCommandBuf(AH, (const char *) ptr, size * nmemb); else { - res = fwrite((void *) ptr, size, nmemb, AH->OF); + res = fwrite(ptr, size, nmemb, AH->OF); if (res != nmemb) die_horribly(AH, modulename, "could not write to output file: %s\n", strerror(errno)); diff --git a/src/bin/pg_dump/pg_backup_files.c b/src/bin/pg_dump/pg_backup_files.c index abc93b14030..afd53bff8e2 100644 --- a/src/bin/pg_dump/pg_backup_files.c +++ b/src/bin/pg_dump/pg_backup_files.c @@ -268,7 +268,7 @@ _WriteData(ArchiveHandle *AH, const void *data, size_t dLen) { lclTocEntry *tctx = (lclTocEntry *) AH->currToc->formatData; - GZWRITE((void *) data, 1, dLen, tctx->FH); + GZWRITE(data, 1, dLen, tctx->FH); return dLen; } diff --git a/src/bin/pg_dump/pg_backup_tar.c b/src/bin/pg_dump/pg_backup_tar.c index 45aab1e2364..4642132d715 100644 --- a/src/bin/pg_dump/pg_backup_tar.c +++ b/src/bin/pg_dump/pg_backup_tar.c @@ -581,7 +581,7 @@ tarWrite(const void *buf, size_t len, TAR_MEMBER *th) size_t res; if (th->zFH != NULL) - res = GZWRITE((void *) buf, 1, len, th->zFH); + res = GZWRITE(buf, 1, len, th->zFH); else res = fwrite(buf, 1, len, th->nFH); @@ -598,7 +598,7 @@ _WriteData(ArchiveHandle *AH, const void *data, size_t dLen) { lclTocEntry *tctx = (lclTocEntry *) AH->currToc->formatData; - dLen = tarWrite((void *) data, dLen, tctx->TH); + dLen = tarWrite(data, dLen, tctx->TH); return dLen; } @@ -797,7 +797,7 @@ _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len) lclContext *ctx = (lclContext *) AH->formatData; size_t res; - res = tarWrite((void *) buf, len, ctx->FH); + res = tarWrite(buf, len, ctx->FH); ctx->filePos += res; return res; } diff --git a/src/bin/pg_dump/pg_dump_sort.c b/src/bin/pg_dump/pg_dump_sort.c index 963f734dce2..efde0d0026b 100644 --- a/src/bin/pg_dump/pg_dump_sort.c +++ b/src/bin/pg_dump/pg_dump_sort.c @@ -138,8 +138,8 @@ sortDumpableObjectsByTypeName(DumpableObject **objs, int numObjs) static int DOTypeNameCompare(const void *p1, const void *p2) { - DumpableObject *obj1 = *(DumpableObject **) p1; - DumpableObject *obj2 = *(DumpableObject **) p2; + DumpableObject *obj1 = *(DumpableObject * const *) p1; + DumpableObject *obj2 = *(DumpableObject * const *) p2; int cmpval; /* Sort by type */ @@ -170,8 +170,8 @@ DOTypeNameCompare(const void *p1, const void *p2) /* To have a stable sort order, break ties for some object types */ if (obj1->objType == DO_FUNC || obj1->objType == DO_AGG) { - FuncInfo *fobj1 = *(FuncInfo **) p1; - FuncInfo *fobj2 = *(FuncInfo **) p2; + FuncInfo *fobj1 = *(FuncInfo * const *) p1; + FuncInfo *fobj2 = *(FuncInfo * const *) p2; cmpval = fobj1->nargs - fobj2->nargs; if (cmpval != 0) @@ -200,8 +200,8 @@ sortDumpableObjectsByTypeOid(DumpableObject **objs, int numObjs) static int DOTypeOidCompare(const void *p1, const void *p2) { - DumpableObject *obj1 = *(DumpableObject **) p1; - DumpableObject *obj2 = *(DumpableObject **) p2; + DumpableObject *obj1 = *(DumpableObject * const *) p1; + DumpableObject *obj2 = *(DumpableObject * const *) p2; int cmpval; cmpval = oldObjectTypePriority[obj1->objType] - diff --git a/src/bin/psql/mbprint.c b/src/bin/psql/mbprint.c index ff9293a07a7..e5fcb387356 100644 --- a/src/bin/psql/mbprint.c +++ b/src/bin/psql/mbprint.c @@ -205,7 +205,7 @@ pg_wcswidth(const unsigned char *pwcs, size_t len, int encoding) * This MUST be kept in sync with pg_wcsformat! */ void -pg_wcssize(unsigned char *pwcs, size_t len, int encoding, +pg_wcssize(const unsigned char *pwcs, size_t len, int encoding, int *result_width, int *result_height, int *result_format_size) { int w, @@ -288,7 +288,7 @@ pg_wcssize(unsigned char *pwcs, size_t len, int encoding, * This MUST be kept in sync with pg_wcssize! */ void -pg_wcsformat(unsigned char *pwcs, size_t len, int encoding, +pg_wcsformat(const unsigned char *pwcs, size_t len, int encoding, struct lineptr * lines, int count) { int w, diff --git a/src/bin/psql/mbprint.h b/src/bin/psql/mbprint.h index f729ef045c7..83050ffcd7e 100644 --- a/src/bin/psql/mbprint.h +++ b/src/bin/psql/mbprint.h @@ -11,8 +11,8 @@ struct lineptr extern unsigned char *mbvalidate(unsigned char *pwcs, int encoding); extern int pg_wcswidth(const unsigned char *pwcs, size_t len, int encoding); -extern void pg_wcsformat(unsigned char *pwcs, size_t len, int encoding, struct lineptr * lines, int count); -extern void pg_wcssize(unsigned char *pwcs, size_t len, int encoding, +extern void pg_wcsformat(const unsigned char *pwcs, size_t len, int encoding, struct lineptr * lines, int count); +extern void pg_wcssize(const unsigned char *pwcs, size_t len, int encoding, int *width, int *height, int *format_size); #endif /* MBPRINT_H */ diff --git a/src/bin/psql/print.c b/src/bin/psql/print.c index 28afcdda743..0d18665566f 100644 --- a/src/bin/psql/print.c +++ b/src/bin/psql/print.c @@ -559,7 +559,7 @@ print_aligned_text(const printTableContent *cont, FILE *fout) nl_lines, bytes_required; - pg_wcssize((unsigned char *) cont->headers[i], strlen(cont->headers[i]), + pg_wcssize((const unsigned char *) cont->headers[i], strlen(cont->headers[i]), encoding, &width, &nl_lines, &bytes_required); if (width > max_width[i]) max_width[i] = width; @@ -583,7 +583,7 @@ print_aligned_text(const printTableContent *cont, FILE *fout) nl_lines, bytes_required; - pg_wcssize((unsigned char *) *ptr, strlen(*ptr), encoding, + pg_wcssize((const unsigned char *) *ptr, strlen(*ptr), encoding, &width, &nl_lines, &bytes_required); if (width > max_width[i % col_count]) @@ -731,7 +731,7 @@ print_aligned_text(const printTableContent *cont, FILE *fout) nl_lines, bytes_required; - pg_wcssize((unsigned char *) *ptr, strlen(*ptr), encoding, + pg_wcssize((const unsigned char *) *ptr, strlen(*ptr), encoding, &width, &nl_lines, &bytes_required); /* @@ -768,7 +768,7 @@ print_aligned_text(const printTableContent *cont, FILE *fout) int width, height; - pg_wcssize((unsigned char *) cont->title, strlen(cont->title), + pg_wcssize((const unsigned char *) cont->title, strlen(cont->title), encoding, &width, &height, NULL); if (width >= width_total) /* Aligned */ @@ -790,7 +790,7 @@ print_aligned_text(const printTableContent *cont, FILE *fout) PRINT_RULE_TOP, format, fout); for (i = 0; i < col_count; i++) - pg_wcsformat((unsigned char *) cont->headers[i], + pg_wcsformat((const unsigned char *) cont->headers[i], strlen(cont->headers[i]), encoding, col_lineptrs[i], max_nl_lines[i]); @@ -861,7 +861,7 @@ print_aligned_text(const printTableContent *cont, FILE *fout) */ for (j = 0; j < col_count; j++) { - pg_wcsformat((unsigned char *) ptr[j], strlen(ptr[j]), encoding, + pg_wcsformat((const unsigned char *) ptr[j], strlen(ptr[j]), encoding, col_lineptrs[j], max_nl_lines[j]); curr_nl_line[j] = 0; } @@ -1146,7 +1146,7 @@ print_aligned_vertical(const printTableContent *cont, FILE *fout) height, fs; - pg_wcssize((unsigned char *) cont->headers[i], strlen(cont->headers[i]), + pg_wcssize((const unsigned char *) cont->headers[i], strlen(cont->headers[i]), encoding, &width, &height, &fs); if (width > hwidth) hwidth = width; @@ -1163,7 +1163,7 @@ print_aligned_vertical(const printTableContent *cont, FILE *fout) height, fs; - pg_wcssize((unsigned char *) *ptr, strlen(*ptr), encoding, + pg_wcssize((const unsigned char *) *ptr, strlen(*ptr), encoding, &width, &height, &fs); if (width > dwidth) dwidth = width; @@ -1219,11 +1219,11 @@ print_aligned_vertical(const printTableContent *cont, FILE *fout) } /* Format the header */ - pg_wcsformat((unsigned char *) cont->headers[i % cont->ncolumns], + pg_wcsformat((const unsigned char *) cont->headers[i % cont->ncolumns], strlen(cont->headers[i % cont->ncolumns]), encoding, hlineptr, hheight); /* Format the data */ - pg_wcsformat((unsigned char *) *ptr, strlen(*ptr), encoding, + pg_wcsformat((const unsigned char *) *ptr, strlen(*ptr), encoding, dlineptr, dheight); line_count = 0; |