Browse code

apm/gpt/mbr: fixed various debug messages apm: passed big parameter by reference

Kevin Lin authored on 2014/03/15 01:49:21
Showing 3 changed files
... ...
@@ -49,7 +49,7 @@
49 49
 #  define apm_parsemsg(...) ;
50 50
 #endif
51 51
 
52
-static int apm_prtn_intxn(cli_ctx *ctx, struct apm_partition_info aptable, size_t sectorsize, int old_school);
52
+static int apm_prtn_intxn(cli_ctx *ctx, struct apm_partition_info *aptable, size_t sectorsize, int old_school);
53 53
 
54 54
 int cli_scanapm(cli_ctx *ctx)
55 55
 {
... ...
@@ -89,8 +89,8 @@ int cli_scanapm(cli_ctx *ctx)
89 89
     /* size of total file must be described by the ddm */
90 90
     maplen = (*ctx->fmap)->real_len;
91 91
     if ((ddm.blockSize * ddm.blockCount) != maplen) {
92
-        cli_dbgmsg("cli_scanapm: File described %u size does not match %u actual size\n",
93
-                   (ddm.blockSize * ddm.blockCount), maplen);
92
+        cli_dbgmsg("cli_scanapm: File described %u size does not match %lu actual size\n",
93
+                   (ddm.blockSize * ddm.blockCount), (unsigned long)maplen);
94 94
         return CL_EFORMAT;
95 95
     }
96 96
 
... ...
@@ -138,7 +138,7 @@ int cli_scanapm(cli_ctx *ctx)
138 138
 
139 139
     /* check that the partition table fits in the space specified - HEURISTICS */
140 140
     if ((ctx->options & CL_SCAN_PARTITION_INTXN) && (ctx->dconf->other & OTHER_CONF_PRTNINTXN)) {
141
-        ret = apm_prtn_intxn(ctx, aptable, sectorsize, old_school);
141
+        ret = apm_prtn_intxn(ctx, &aptable, sectorsize, old_school);
142 142
         if (ret != CL_CLEAN) {
143 143
             if ((ctx->options & CL_SCAN_ALLMATCHES) && (ret == CL_VIRUS))
144 144
                 detection = CL_VIRUS;
... ...
@@ -153,10 +153,10 @@ int cli_scanapm(cli_ctx *ctx)
153 153
     cli_dbgmsg("Type: %s\n", (char*)aptable.type);
154 154
     cli_dbgmsg("Signature: %x\n", aptable.signature);
155 155
     cli_dbgmsg("Partition Count: %u\n", aptable.numPartitions);
156
-    cli_dbgmsg("Blocks: [%u, +%u), ([%u, +%u))\n",
156
+    cli_dbgmsg("Blocks: [%u, +%u), ([%lu, +%lu))\n",
157 157
                aptable.pBlockStart, aptable.pBlockCount,
158
-               (aptable.pBlockStart * sectorsize),
159
-               (aptable.pBlockCount * sectorsize));
158
+               (unsigned long)(aptable.pBlockStart * sectorsize),
159
+               (unsigned long)(aptable.pBlockCount * sectorsize));
160 160
 
161 161
     /* check engine maxpartitions limit */
162 162
     if (aptable.numPartitions < ctx->engine->maxpartitions) {
... ...
@@ -244,7 +244,7 @@ int cli_scanapm(cli_ctx *ctx)
244 244
     return detection;
245 245
 }
246 246
 
247
-static int apm_prtn_intxn(cli_ctx *ctx, struct apm_partition_info aptable, size_t sectorsize, int old_school)
247
+static int apm_prtn_intxn(cli_ctx *ctx, struct apm_partition_info *aptable, size_t sectorsize, int old_school)
248 248
 {
249 249
     prtn_intxn_list_t prtncheck;
250 250
     struct apm_partition_info apentry;
... ...
@@ -256,8 +256,8 @@ static int apm_prtn_intxn(cli_ctx *ctx, struct apm_partition_info aptable, size_
256 256
     prtn_intxn_list_init(&prtncheck);
257 257
 
258 258
     /* check engine maxpartitions limit */
259
-    if (aptable.numPartitions < ctx->engine->maxpartitions) {
260
-        max_prtns = aptable.numPartitions;
259
+    if (aptable->numPartitions < ctx->engine->maxpartitions) {
260
+        max_prtns = aptable->numPartitions;
261 261
     }
262 262
     else {
263 263
         max_prtns = ctx->engine->maxpartitions;
... ...
@@ -121,7 +121,7 @@ int cli_scangpt(cli_ctx *ctx, size_t sectorsize)
121 121
     /* sector size calculatation */
122 122
     if (sectorsize == 0) {
123 123
         sectorsize = gpt_detect_size((*ctx->fmap));
124
-        cli_dbgmsg("cli_scangpt: detected %u sector size\n", sectorsize);
124
+        cli_dbgmsg("cli_scangpt: detected %lu sector size\n", (unsigned long)sectorsize);
125 125
     }
126 126
     if (sectorsize == 0) {
127 127
         cli_errmsg("cli_scangpt: could not detemine sector size\n");
... ...
@@ -131,8 +131,8 @@ int cli_scangpt(cli_ctx *ctx, size_t sectorsize)
131 131
     /* size of total file must be a multiple of the sector size */
132 132
     maplen = (*ctx->fmap)->real_len;
133 133
     if ((maplen % sectorsize) != 0) {
134
-        cli_dbgmsg("cli_scangpt: File sized %u is not a multiple of sector size %u\n",
135
-                   maplen, sectorsize);
134
+        cli_dbgmsg("cli_scangpt: File sized %lu is not a multiple of sector size %lu\n",
135
+                   (unsigned long)maplen, (unsigned long)sectorsize);
136 136
         return CL_EFORMAT;
137 137
     }
138 138
 
... ...
@@ -114,8 +114,8 @@ int cli_mbr_check2(cli_ctx *ctx, size_t sectorsize) {
114 114
     /* size of total file must be a multiple of the sector size */
115 115
     maplen = (*ctx->fmap)->real_len;
116 116
     if ((maplen % sectorsize) != 0) {
117
-        cli_dbgmsg("cli_scanmbr: File sized %u is not a multiple of sector size %u\n",
118
-                   maplen, sectorsize);
117
+        cli_dbgmsg("cli_scanmbr: File sized %lu is not a multiple of sector size %lu\n",
118
+                   (unsigned long)maplen, (unsigned long)sectorsize);
119 119
         return CL_EFORMAT;
120 120
     }
121 121
 
... ...
@@ -160,8 +160,8 @@ int cli_scanmbr(cli_ctx *ctx, size_t sectorsize)
160 160
     /* size of total file must be a multiple of the sector size */
161 161
     maplen = (*ctx->fmap)->real_len;
162 162
     if ((maplen % sectorsize) != 0) {
163
-        cli_dbgmsg("cli_scanmbr: File sized %u is not a multiple of sector size %u\n",
164
-                   maplen, sectorsize);
163
+        cli_dbgmsg("cli_scanmbr: File sized %lu is not a multiple of sector size %lu\n",
164
+                   (unsigned long)maplen, (unsigned long)sectorsize);
165 165
         return CL_EFORMAT;
166 166
     }
167 167
 
... ...
@@ -210,10 +210,10 @@ int cli_scanmbr(cli_ctx *ctx, size_t sectorsize)
210 210
         cli_dbgmsg("MBR Partition Entry %u:\n", i);
211 211
         cli_dbgmsg("Status: %u\n", mbr.entries[i].status);
212 212
         cli_dbgmsg("Type: %x\n", mbr.entries[i].type);
213
-        cli_dbgmsg("Blocks: [%u, +%u), ([%u, +%u))\n",
213
+        cli_dbgmsg("Blocks: [%u, +%u), ([%lu, +%lu))\n",
214 214
                    mbr.entries[i].firstLBA, mbr.entries[i].numLBA,
215
-                   (mbr.entries[i].firstLBA * sectorsize),
216
-                   (mbr.entries[i].numLBA * sectorsize));
215
+                   (unsigned long)(mbr.entries[i].firstLBA * sectorsize),
216
+                   (unsigned long)(mbr.entries[i].numLBA * sectorsize));
217 217
 
218 218
         /* Handle MBR entry based on type */
219 219
         if (mbr.entries[i].type == MBR_EMPTY) {
... ...
@@ -306,10 +306,10 @@ static int mbr_scanextprtn(cli_ctx *ctx, unsigned *prtncount, off_t extlba, size
306 306
                 cli_dbgmsg("Logical Partition Entry %u:\n", j);
307 307
                 cli_dbgmsg("Status: %u\n", ebr.entries[j].status);
308 308
                 cli_dbgmsg("Type: %x\n", ebr.entries[j].type);
309
-                cli_dbgmsg("Blocks: [%u, +%u), ([%u, +%u))\n",
309
+                cli_dbgmsg("Blocks: [%u, +%u), ([%lu, +%lu))\n",
310 310
                            ebr.entries[j].firstLBA, ebr.entries[j].numLBA,
311
-                           (ebr.entries[j].firstLBA * sectorsize),
312
-                           (ebr.entries[j].numLBA * sectorsize));
311
+                           (unsigned long)(ebr.entries[j].firstLBA * sectorsize),
312
+                           (unsigned long)(ebr.entries[j].numLBA * sectorsize));
313 313
 
314 314
                 if (ebr.entries[j].type == MBR_EMPTY) {
315 315
                     /* empty partiton entry */