Mercurial > hg > dmlib
comparison tools/objlink.c @ 2004:161e731eb152
Improve dmGetIntVal() to accept an optional negative value boolean flag
pointer. Also improve error handling in it.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 07 Jul 2018 01:11:22 +0300 |
parents | bd68c9adc7ca |
children | bec158e00f17 |
comparison
equal
deleted
inserted
replaced
2003:2ae47dcaaf10 | 2004:161e731eb152 |
---|---|
257 } | 257 } |
258 sectMode = *sep; | 258 sectMode = *sep; |
259 *sep = 0; | 259 *sep = 0; |
260 | 260 |
261 // Get value | 261 // Get value |
262 if (!dmGetIntVal(str, sectStart)) | 262 if (!dmGetIntVal(str, sectStart, NULL)) |
263 { | 263 { |
264 dmErrorMsg("Section start address '%s' in '%s' invalid.\n", str, arg); | 264 dmErrorMsg("Section start address '%s' in '%s' invalid.\n", str, arg); |
265 goto out; | 265 goto out; |
266 } | 266 } |
267 | 267 |
286 arg, namesep); | 286 arg, namesep); |
287 goto out; | 287 goto out; |
288 } | 288 } |
289 | 289 |
290 // Get end address or length | 290 // Get end address or length |
291 if (!dmGetIntVal(sep + 1, &tmpi)) | 291 if (!dmGetIntVal(sep + 1, &tmpi, NULL)) |
292 { | 292 { |
293 dmErrorMsg("Section %s '%s' in '%s' invalid.\n", | 293 dmErrorMsg("Section %s '%s' in '%s' invalid.\n", |
294 sectMode == '-' ? "end address" : "length", | 294 sectMode == '-' ? "end address" : "length", |
295 sep + 1, arg); | 295 sep + 1, arg); |
296 goto out; | 296 goto out; |
326 char *sep; | 326 char *sep; |
327 | 327 |
328 if ((sep = strrchr(arg, ':')) != NULL) | 328 if ((sep = strrchr(arg, ':')) != NULL) |
329 { | 329 { |
330 *sep = 0; | 330 *sep = 0; |
331 if (!dmGetIntVal(sep + 1, &tmpi)) | 331 if (!dmGetIntVal(sep + 1, &tmpi, NULL)) |
332 { | 332 { |
333 dmErrorMsg("Invalid %s address '%s' specified for '%s'.\n", | 333 dmErrorMsg("Invalid %s address '%s' specified for '%s'.\n", |
334 desc, sep + 1, arg); | 334 desc, sep + 1, arg); |
335 return FALSE; | 335 return FALSE; |
336 } | 336 } |
436 dmErrorMsg("Invalid init value type '%c' specified for '%s'.\n", | 436 dmErrorMsg("Invalid init value type '%c' specified for '%s'.\n", |
437 p[1], optArg); | 437 p[1], optArg); |
438 return FALSE; | 438 return FALSE; |
439 } | 439 } |
440 } | 440 } |
441 if (!dmGetIntVal(optArg, &tmpi)) | 441 if (!dmGetIntVal(optArg, &tmpi, NULL)) |
442 { | 442 { |
443 dmErrorMsg("Invalid initvalue '%s'.\n", optArg); | 443 dmErrorMsg("Invalid initvalue '%s'.\n", optArg); |
444 return FALSE; | 444 return FALSE; |
445 } | 445 } |
446 optInitValue = tmpi; | 446 optInitValue = tmpi; |
486 // Set loading address | 486 // Set loading address |
487 if (strcasecmp(optArg, "none") == 0) | 487 if (strcasecmp(optArg, "none") == 0) |
488 optLoadAddress = LA_NONE; | 488 optLoadAddress = LA_NONE; |
489 else | 489 else |
490 { | 490 { |
491 if (!dmGetIntVal(optArg, &tmpi)) | 491 if (!dmGetIntVal(optArg, &tmpi, NULL)) |
492 { | 492 { |
493 dmErrorMsg("Invalid loading address '%s'.\n", optArg); | 493 dmErrorMsg("Invalid loading address '%s'.\n", optArg); |
494 return FALSE; | 494 return FALSE; |
495 } | 495 } |
496 if (tmpi >= 64*1024) | 496 if (tmpi >= 64*1024) |