Skip to content

Commit

Permalink
[sparse] fix most sparse warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jbnote committed Dec 29, 2007
1 parent 9be68de commit 4efcbe5
Show file tree
Hide file tree
Showing 16 changed files with 78 additions and 71 deletions.
1 change: 0 additions & 1 deletion _far_v4.h
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,6 @@ _typed_col_of_far(const id_vlx_t chiptype,
switch (type) {
case V4_TYPE_CLB:
{
const unsigned col = addr->col;
const unsigned end = bitdescr[chiptype].col_count[V4_TYPE_CLB] - 1;
const unsigned middle = end >> 1;
const unsigned dsp = DSP_V4_OF_END(end);
Expand Down
3 changes: 2 additions & 1 deletion altera/bitstream.c
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,8 @@ dump_lab(const altera_bitstream_t *bitstream,
void
dump_lab_data(const gchar *odir,
const altera_bitstream_t *bitstream) {
iterate_over_labs(bitstream, dump_lab, (void*)odir);
void *arg = (void *) odir;
iterate_over_labs(bitstream, dump_lab, arg);
}

static void
Expand Down
6 changes: 3 additions & 3 deletions altera/debit.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ unsigned int debit_debug = 0;

static void
debit_reverse(const altera_bitstream_t *altera,
const gchar ** coords) {
const gchar ** acoords) {
const gchar *scoord;

if (!coords)
if (!acoords)
return;

while ( (scoord = *coords++) != NULL) {
while ( (scoord = *acoords++) != NULL) {
unsigned long coord = strtoul(scoord, NULL, 0);
print_pos_from_bit_offset(altera, coord);
}
Expand Down
19 changes: 10 additions & 9 deletions bit2pdf.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,21 +90,22 @@ static const char *tnames[OTYPE_END] = {
[SVG] = "svg",
};

static out_type_t get_optype(const char *otype) {
static out_type_t get_optype(const char *lotype) {
int i;
if (!otype)
if (!lotype)
return PNG;

for (i = 0; i < OTYPE_END; i++) {
if (!strcmp(otype,tnames[i]))
if (!strcmp(lotype,tnames[i]))
return i;
}
g_warning("unknown requested type %s, selecting PNG", otype);
g_warning("unknown requested type %s, selecting PNG", lotype);
return PNG;
}

static int
draw_bitstream(const bitstream_analyzed_t *nlz, const gchar *ofile, const out_type_t out) {
draw_bitstream(const bitstream_analyzed_t *nlz, const gchar *lofile,
const out_type_t out) {
chip_descr_t *chip = nlz->chip;
cairo_surface_t *sr;
cairo_t *cr;
Expand All @@ -114,21 +115,21 @@ draw_bitstream(const bitstream_analyzed_t *nlz, const gchar *ofile, const out_ty
switch (out) {
#ifdef PDF_CAIRO
case PDF:
sr = cairo_pdf_surface_create (ofile,
sr = cairo_pdf_surface_create (lofile,
chip->width * SITE_WIDTH,
chip->height * SITE_HEIGHT);
break;
#endif /* PDF_CAIRO */
#ifdef PS_CAIRO
case PS:
sr = cairo_ps_surface_create (ofile,
sr = cairo_ps_surface_create (lofile,
chip->width * SITE_WIDTH,
chip->height * SITE_HEIGHT);
break;
#endif /* PS_CAIRO */
#ifdef SVG_CAIRO
case SVG:
sr = cairo_svg_surface_create (ofile,
sr = cairo_svg_surface_create (lofile,
chip->width * SITE_WIDTH,
chip->height * SITE_HEIGHT);
break;
Expand Down Expand Up @@ -158,7 +159,7 @@ draw_bitstream(const bitstream_analyzed_t *nlz, const gchar *ofile, const out_ty
break;
#endif /* PDF_CAIRO || PS_CAIRO */
case PNG:
(void) cairo_surface_write_to_png (sr, ofile);
(void) cairo_surface_write_to_png (sr, lofile);
break;
default:
err = -1;
Expand Down
10 changes: 5 additions & 5 deletions bitstream.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,12 +284,12 @@ query_bitstream_site_bytea(const bitstream_parsed_t *bitstream,
const csite_descr_t *site,
const unsigned cfgbit) {
const chip_struct_t *chip_struct = bitstream->chip_struct;
const guint site_type = site->type;
const guint lsite_type = site->type;
const guint x = site->type_coord.x;
const guint y = site->type_coord.y;
const guint y_width = type_bits[site_type].y_width;
const guint y_width = type_bits[lsite_type].y_width;
const guint flen = chip_struct->framelen * sizeof(uint32_t);
const gint y_offset = type_bits[site_type].y_offset;
const gint y_offset = type_bits[lsite_type].y_offset;

/* site offset in the y axis -- inverted. Should not be done here maybe */
const guint y_type_offset = (y_offset >= 0) ? (unsigned)y_offset : (flen + y_offset);
Expand All @@ -301,8 +301,8 @@ query_bitstream_site_bytea(const bitstream_parsed_t *bitstream,
/* The database could be changed to have only one add here */
const gsize frame_offset = site_off + yoff;

const gchar *frame = get_frame(bitstream, type_bits[site_type].col_type,
x+type_bits[site_type].x_type_off, xoff);
const gchar *frame = get_frame(bitstream, type_bits[lsite_type].col_type,
x+type_bits[lsite_type].x_type_off, xoff);

/* debit_log(L_FILEPOS, "querying site t%u, (%u,%u), cfgbit %u", */
/* site->type, site->type_coord.x, site->type_coord.y, cfgbit); */
Expand Down
26 changes: 13 additions & 13 deletions bitstream_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -610,10 +610,10 @@ char *type_names[V2C__NB_CFG] = {
void
typed_frame_name(char *buf, unsigned buf_len,
const unsigned type,
const unsigned index,
const unsigned idx,
const unsigned frameid) {
snprintf(buf, buf_len, "frame_%s_%02x_%02x",
type_names[type], index, frameid);
type_names[type], idx, frameid);
}

int
Expand Down Expand Up @@ -923,20 +923,20 @@ void record_frame(bitstream_parsed_t *parsed,
bitstream_parser_t *bitstream,
const guint32 myfar) {
sw_far_t far;
guint type, index, frame;
guint type, idx, frame;
const char *dataframe = bitstream->last_frame;
const char **frame_loc;

fill_swfar(&far, myfar);

type = _type_of_far(bitstream->type, &far);
index = _col_of_far(bitstream->type, &far);
idx = _col_of_far(bitstream->type, &far);
frame = far.mna;

debit_log(L_BITSTREAM,"flushing frame [type:%i,index:%02i,frame:%2X]",
type, index, frame);
type, idx, frame);

frame_loc = get_frame_loc(parsed, type, index, frame);
frame_loc = get_frame_loc(parsed, type, idx, frame);
if (*frame_loc != NULL)
g_warning("Overwriting already present frame");
*frame_loc = dataframe;
Expand Down Expand Up @@ -1064,18 +1064,18 @@ iterate_over_frames(const bitstream_parsed_t *parsed,
const chip_struct_t *chip_struct = parsed->chip_struct;
const unsigned *col_counts = chip_struct->col_count;
const unsigned *frame_counts = chip_struct->frame_count;
guint type, index, frame;
guint type, idx, frame;

/* Iterate over the whole thing */
for (type = 0; type < V2C__NB_CFG; type++) {
const guint col_count = col_counts[type];

for (index = 0; index < col_count; index++) {
for (idx = 0; idx < col_count; idx++) {
const guint frame_count = frame_counts[type];

for (frame = 0; frame < frame_count; frame++) {
const gchar *data = get_frame(parsed, type, index, frame);
iter(data, type, index, frame, itdat);
const gchar *data = get_frame(parsed, type, idx, frame);
iter(data, type, idx, frame, itdat);
}
}
}
Expand All @@ -1098,11 +1098,11 @@ iterate_over_frames_far(const bitstream_parsed_t *parsed,
/* Iterate over the whole thing very dumbly */
while (!_last_frame(chip_id, &far)) {
const int type = _type_of_far(chip_id, &far);
const int index = _col_of_far(chip_id, &far);
const int idx = _col_of_far(chip_id, &far);
const int frame = far.mna;
const gchar *data = get_frame(parsed, type, index, frame);
const gchar *data = get_frame(parsed, type, idx, frame);

iter(data, type, index, frame, itdat);
iter(data, type, idx, frame, itdat);
_far_increment_mna(chip_id, &far);
}
}
Expand Down
4 changes: 2 additions & 2 deletions bitstream_parser_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ update_crc(bitstream_parser_t *parser,
void
typed_frame_name(char *buf, unsigned buf_len,
const unsigned type,
const unsigned index,
const unsigned idx,
const unsigned frameid) {
(void) buf; (void) buf_len; (void) type; (void) index; (void) frameid;
(void) buf; (void) buf_len; (void) type; (void) idx; (void) frameid;
}

static inline void
Expand Down
8 changes: 4 additions & 4 deletions bitstream_v4.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ query_bitstream_site_byte(const bitstream_parsed_t *bitstream,
const csite_descr_t *site,
const int cfgbyte) {
const chip_struct_t *chip_struct = bitstream->chip_struct;
const site_type_t site_type = site->type;
const site_type_t lsite_type = site->type;
const unsigned x = site->type_coord.x;
const unsigned y = site->type_coord.y;
const unsigned ymid = chip_struct->row_count;
Expand All @@ -170,7 +170,7 @@ query_bitstream_site_byte(const bitstream_parsed_t *bitstream,

/* When top is one, the row numbering is inverted, and bits are mirrored */
row = top ? (ymid - 1 - row) : row - ymid;
frame = get_frame(bitstream, type_bits[site_type].col_type, row, top, x, frame_x);
frame = get_frame(bitstream, type_bits[lsite_type].col_type, row, top, x, frame_x);
frame_y = top ? (164 - 1 - frame_y) : frame_y;

/* The adressing here is a bit strange, due to the frame byte order */
Expand All @@ -185,7 +185,7 @@ query_bitstream_site_byte(const bitstream_parsed_t *bitstream,
const csite_descr_t *site,
const int cfgbyte) {
const chip_struct_t *chip_struct = bitstream->chip_struct;
const site_type_t site_type = site->type;
const site_type_t lsite_type = site->type;
const unsigned x = site->type_coord.x;
const unsigned y = site->type_coord.y;
const unsigned ymid = chip_struct->row_count;
Expand All @@ -204,7 +204,7 @@ query_bitstream_site_byte(const bitstream_parsed_t *bitstream,

/* When top is one, the row numbering is inverted */
row = top ? (ymid - 1 - row) : row - ymid;
frame = get_frame(bitstream, type_bits[site_type].col_type, row, top, x, frame_x);
frame = get_frame(bitstream, type_bits[lsite_type].col_type, row, top, x, frame_x);

/* The adressing here is a bit strange, due to the frame byte order */
return frame[frame_y ^ 0x3];
Expand Down
4 changes: 2 additions & 2 deletions bitstream_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -553,11 +553,11 @@ bs_write_padding(bitstream_writer_t *writer, const unsigned rega, const unsigned
}

static void
write_frame(const char *frame, guint type, guint index, guint frameidx, void *data) {
write_frame(const char *frame, guint type, guint idx, guint frameidx, void *data) {
bitstream_writer_t *writer = data;
const chip_struct_t *chip = writer->bit->chip_struct;
const unsigned frame_len = chip->framelen * sizeof(uint32_t);
(void) type; (void) index; (void) frameidx;
(void) type; (void) idx; (void) frameidx;

/* unlikely */
if (!frame) {
Expand Down
10 changes: 5 additions & 5 deletions design_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,20 @@ const gchar **get_frame_loc(const bitstream_parsed_t *parsed,
const guint type,
const guint row,
const guint top,
const guint index,
const guint idx,
const guint frame) {
const chip_struct_t *chip_struct = parsed->chip_struct;
const unsigned rowcount = chip_struct->row_count;
const unsigned framecount = chip_struct->frame_count[type];
const unsigned *col_count = chip_struct->col_count;
g_assert(type < V__NB_CFG);
g_assert(index < type_col_count(col_count, type));
g_assert(idx < type_col_count(col_count, type));
g_assert(row < rowcount);
g_assert(frame < framecount);
(void) col_count;

/* This is a double-lookup method */
return &parsed->frames[type][ framecount * ((index * 2 + top) * rowcount + row)
return &parsed->frames[type][ framecount * ((idx * 2 + top) * rowcount + row)
+ frame ];
}

Expand All @@ -52,9 +52,9 @@ const gchar *get_frame(const bitstream_parsed_t *parsed,
const guint type,
const guint row,
const guint top,
const guint index,
const guint idx,
const guint frame) {
const gchar *frameptr = *get_frame_loc(parsed, type, row, top, index, frame);
const gchar *frameptr = *get_frame_loc(parsed, type, row, top, idx, frame);
g_assert(frameptr != NULL);
return frameptr;
}
Expand Down
10 changes: 5 additions & 5 deletions design_s3.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,18 +144,18 @@ get_hwfar(const sw_far_t *sw_far) {
static inline
const gchar **get_frame_loc(const bitstream_parsed_t *parsed,
const guint type,
const guint index,
const guint idx,
const guint frame) {
const chip_struct_t *chip_struct = parsed->chip_struct;
const unsigned *col_count = chip_struct->col_count;
const unsigned *frame_count = chip_struct->frame_count;
g_assert(type < V2C__NB_CFG);
g_assert(index < col_count[type]);
g_assert(idx < col_count[type]);
g_assert(frame < frame_count[type]);
(void) col_count;

/* This is a double-lookup method */
return &parsed->frames[type][index * frame_count[type] + frame];
return &parsed->frames[type][idx * frame_count[type] + frame];
}

/* FDRI handling. Requires FAR handling.
Expand All @@ -164,9 +164,9 @@ const gchar **get_frame_loc(const bitstream_parsed_t *parsed,
static inline
const gchar *get_frame(const bitstream_parsed_t *parsed,
const guint type,
const guint index,
const guint idx,
const guint frame) {
const gchar *frameptr = *get_frame_loc(parsed, type, index, frame);
const gchar *frameptr = *get_frame_loc(parsed, type, idx, frame);
g_assert(frameptr != NULL);
return frameptr;
}
Expand Down
10 changes: 5 additions & 5 deletions design_v2.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,18 +144,18 @@ get_hwfar(const sw_far_t *sw_far) {
static inline
const gchar **get_frame_loc(const bitstream_parsed_t *parsed,
const guint type,
const guint index,
const guint idx,
const guint frame) {
const chip_struct_t *chip_struct = parsed->chip_struct;
const unsigned *col_count = chip_struct->col_count;
const unsigned *frame_count = chip_struct->frame_count;
g_assert(type < V2C__NB_CFG);
g_assert(index < col_count[type]);
g_assert(idx < col_count[type]);
g_assert(frame < frame_count[type]);
(void) col_count;

/* This is a double-lookup method */
return &parsed->frames[type][index * frame_count[type] + frame];
return &parsed->frames[type][idx * frame_count[type] + frame];
}

/* FDRI handling. Requires FAR handling.
Expand All @@ -164,9 +164,9 @@ const gchar **get_frame_loc(const bitstream_parsed_t *parsed,
static inline
const gchar *get_frame(const bitstream_parsed_t *parsed,
const guint type,
const guint index,
const guint idx,
const guint frame) {
const gchar *frameptr = *get_frame_loc(parsed, type, index, frame);
const gchar *frameptr = *get_frame_loc(parsed, type, idx, frame);
g_assert(frameptr != NULL);
return frameptr;
}
Expand Down
Loading

0 comments on commit 4efcbe5

Please sign in to comment.