Skip to content

Commit

Permalink
tools/firewire: nosy-dump: fix it on x86-64
Browse files Browse the repository at this point in the history
Replace 'unsigned long' and the (unaffected) 'unsigned int' by uint32_t
if they represent quadlets.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
  • Loading branch information
Stefan Richter committed Jul 27, 2010
1 parent 9f6d3c4 commit 1bcc69f
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 209 deletions.
12 changes: 6 additions & 6 deletions tools/firewire/decode-fcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,12 @@ static const struct avc_opcode_info opcode_info[256] = {
};

struct avc_frame {
unsigned int operand0 : 8;
unsigned int opcode : 8;
unsigned int subunit_id : 3;
unsigned int subunit_type : 5;
unsigned int ctype : 4;
unsigned int cts : 4;
uint32_t operand0:8;
uint32_t opcode:8;
uint32_t subunit_id:3;
uint32_t subunit_type:5;
uint32_t ctype:4;
uint32_t cts:4;
};

static void
Expand Down
37 changes: 18 additions & 19 deletions tools/firewire/nosy-dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ enum {
};

static void
print_packet(unsigned long *data, size_t length);
print_packet(uint32_t *data, size_t length);
static void
decode_link_packet(struct link_packet *packet, size_t length,
int include_flags, int exclude_flags);
Expand Down Expand Up @@ -151,7 +151,7 @@ sigint_handler(int signal_num)
}

struct subaction *
subaction_create(unsigned long *data, size_t length)
subaction_create(uint32_t *data, size_t length)
{
struct subaction *sa;

Expand Down Expand Up @@ -247,9 +247,9 @@ handle_transaction(struct link_transaction *t)

if (option_verbose) {
list_for_each_entry(sa, &t->request_list, link)
print_packet((unsigned long *) &sa->packet, sa->length);
print_packet((uint32_t *) &sa->packet, sa->length);
list_for_each_entry(sa, &t->response_list, link)
print_packet((unsigned long *) &sa->packet, sa->length);
print_packet((uint32_t *) &sa->packet, sa->length);
}
printf("\r\n");

Expand Down Expand Up @@ -506,7 +506,7 @@ static struct packet_info packet_info[] = {
};

int
handle_packet(unsigned long *data, size_t length)
handle_packet(uint32_t *data, size_t length)
{
if (length == 0) {
printf("bus reset\r\n");
Expand Down Expand Up @@ -642,8 +642,8 @@ handle_packet(unsigned long *data, size_t length)

unsigned int get_bits(struct link_packet *packet, int offset, int width)
{
unsigned long *data = (unsigned long *) packet;
unsigned long index, shift, mask;
uint32_t *data = (uint32_t *) packet;
uint32_t index, shift, mask;

index = offset / 32 + 1;
shift = 32 - (offset & 31) - width;
Expand Down Expand Up @@ -703,7 +703,7 @@ decode_link_packet(struct link_packet *packet, size_t length,
offset = f->offset;

if (f->value_names != NULL) {
unsigned long bits;
uint32_t bits;

bits = get_bits(packet, offset, f->width);
printf("%s", f->value_names[bits]);
Expand Down Expand Up @@ -741,18 +741,18 @@ decode_link_packet(struct link_packet *packet, size_t length,
}

static void
print_packet(unsigned long *data, size_t length)
print_packet(uint32_t *data, size_t length)
{
int i;

printf("%6lu ", data[0]);
printf("%6u ", data[0]);

if (length == 4)
printf("bus reset");
else if (length < sizeof(struct phy_packet)) {
printf("short packet: ");
for (i = 1; i < length / 4; i++)
printf("%s%08lx", i == 0 ? "[" : " ", data[i]);
printf("%s%08x", i == 0 ? "[" : " ", data[i]);
printf("]");

}
Expand Down Expand Up @@ -803,7 +803,7 @@ print_packet(unsigned long *data, size_t length)
default:
printf("unknown phy packet: ");
for (i = 1; i < length / 4; i++)
printf("%s%08lx", i == 0 ? "[" : " ", data[i]);
printf("%s%08x", i == 0 ? "[" : " ", data[i]);
printf("]");
break;
}
Expand All @@ -829,7 +829,7 @@ print_packet(unsigned long *data, size_t length)
#define CLEAR "\033[H\033[2J"

static void
print_stats(unsigned long *data, size_t length)
print_stats(uint32_t *data, size_t length)
{
static int bus_reset_count, short_packet_count, phy_packet_count;
static int tcode_count[16];
Expand Down Expand Up @@ -959,20 +959,19 @@ int main(int argc, const char *argv[])
setvbuf(stdout, NULL, _IOLBF, BUFSIZ);

if (1) {
unsigned long buf[128 * 1024];
unsigned int filter;
uint32_t buf[128 * 1024];
uint32_t filter;
int length;

filter = ~0;
if (!option_iso)
filter &= ~(1 <<TCODE_ISO_DATA);
if (!option_cycle_start)
filter &= ~(1 << TCODE_CYCLE_START);

if (view == VIEW_STATS)
ioctl(fd, NOSY_IOC_FILTER, ~(1 << TCODE_CYCLE_START));
else
ioctl(fd, NOSY_IOC_FILTER, filter);
filter = ~(1 << TCODE_CYCLE_START);

ioctl(fd, NOSY_IOC_FILTER, filter);

ioctl(fd, NOSY_IOC_START);

Expand Down
Loading

0 comments on commit 1bcc69f

Please sign in to comment.