Clean up field assignments
[yaffs2.git] / yaffs_packedtags1.c
1 #include "yaffs_packedtags1.h"
2 #include "yportenv.h"
3
4 void yaffs_PackTags1(yaffs_PackedTags1 *pt, const yaffs_ExtendedTags *t)
5 {
6         pt->chunkId = t->chunkId;
7         pt->serialNumber = t->serialNumber;
8         pt->byteCount = t->byteCount;
9         pt->objectId = t->objectId;
10         pt->ecc = 0;
11         pt->deleted = (t->chunkDeleted) ? 0 : 1;
12         pt->unusedStuff = 0;
13         pt->shouldBeFF = 0xFFFFFFFF;
14         
15 }
16
17 void yaffs_UnpackTags1(yaffs_ExtendedTags *t, const yaffs_PackedTags1 *pt)
18 {
19         static const __u8 allFF[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,0xff, 0xff, 0xff, 0xff};
20         
21         if(memcmp(allFF,pt,sizeof(yaffs_PackedTags1)))
22         {
23                 t->blockBad = 0;
24                 if(pt->shouldBeFF != 0xFFFFFFFF)
25                 {
26                         t->blockBad = 1;
27                 }
28                 t->chunkUsed = 1;
29                 t->objectId = pt->objectId;
30                 t->chunkId = pt->chunkId;
31                 t->byteCount = pt->byteCount;
32                 t->eccResult =  YAFFS_ECC_RESULT_NO_ERROR;
33                 t->chunkDeleted = (pt->deleted) ? 0 : 1;
34                 t->serialNumber = pt->serialNumber;
35         }
36         else
37         {
38                 memset(t,0,sizeof(yaffs_ExtendedTags));
39                 
40         }
41 }
42