Messages in this thread | | | Date | Mon, 7 Jan 2008 12:29:34 +0000 | From | Christoph Hellwig <> | Subject | Re: [PATCH 2/7] udf: create common function for tag checksumming |
| |
> --- a/fs/udf/udfdecl.h > +++ b/fs/udf/udfdecl.h > @@ -36,6 +36,18 @@ > > #define udf_get_lb_pblock(sb,loc,offset) udf_get_pblock((sb), (loc).logicalBlockNum, (loc).partitionReferenceNum, (offset)) > > +/* computes tag checksum */ > +static inline uint8_t udf_tag_checksum(const tag *t) > +{ > + uint8_t *data = (uint8_t *)t; > + uint8_t checksum = 0; > + int i; > + for (i = 0; i < sizeof(tag); ++i) > + if (i != 4) /* that's the position of checksum */ > + checksum += data[i]; > + return checksum; > +}
This function is large enough that it should be out of line in a .c file. Also I'd prefer using the Linux native types ala:
/* computes tag checksum */ static u8 udf_tag_checksum(const tag *t) { u8 *data = (u8 *)t; u8 checksum = 0; int i;
for (i = 0; i < sizeof(tag); i++) { if (i != 4) /* position of the checksum */ checksum += data[i]; }
return checksum; }
| |