diff options
Diffstat (limited to 'scripts/mod/sumversion.c')
-rw-r--r-- | scripts/mod/sumversion.c | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c index 43271a1ca01e..8a2875689e4d 100644 --- a/scripts/mod/sumversion.c +++ b/scripts/mod/sumversion.c | |||
@@ -316,8 +316,7 @@ static int parse_source_files(const char *objfile, struct md4_ctx *md) | |||
316 | 316 | ||
317 | file = grab_file(cmd, &flen); | 317 | file = grab_file(cmd, &flen); |
318 | if (!file) { | 318 | if (!file) { |
319 | fprintf(stderr, "Warning: could not find %s for %s\n", | 319 | warn("could not find %s for %s\n", cmd, objfile); |
320 | cmd, objfile); | ||
321 | goto out; | 320 | goto out; |
322 | } | 321 | } |
323 | 322 | ||
@@ -355,9 +354,8 @@ static int parse_source_files(const char *objfile, struct md4_ctx *md) | |||
355 | /* Check if this file is in same dir as objfile */ | 354 | /* Check if this file is in same dir as objfile */ |
356 | if ((strstr(line, dir)+strlen(dir)-1) == strrchr(line, '/')) { | 355 | if ((strstr(line, dir)+strlen(dir)-1) == strrchr(line, '/')) { |
357 | if (!parse_file(line, md)) { | 356 | if (!parse_file(line, md)) { |
358 | fprintf(stderr, | 357 | warn("could not open %s: %s\n", |
359 | "Warning: could not open %s: %s\n", | 358 | line, strerror(errno)); |
360 | line, strerror(errno)); | ||
361 | goto out_file; | 359 | goto out_file; |
362 | } | 360 | } |
363 | 361 | ||
@@ -383,8 +381,11 @@ void get_src_version(const char *modname, char sum[], unsigned sumlen) | |||
383 | struct md4_ctx md; | 381 | struct md4_ctx md; |
384 | char *sources, *end, *fname; | 382 | char *sources, *end, *fname; |
385 | const char *basename; | 383 | const char *basename; |
386 | char filelist[strlen(getenv("MODVERDIR")) + strlen("/") + | 384 | char filelist[PATH_MAX + 1]; |
387 | strlen(modname) - strlen(".o") + strlen(".mod") + 1 ]; | 385 | char *modverdir = getenv("MODVERDIR"); |
386 | |||
387 | if (!modverdir) | ||
388 | modverdir = "."; | ||
388 | 389 | ||
389 | /* Source files for module are in .tmp_versions/modname.mod, | 390 | /* Source files for module are in .tmp_versions/modname.mod, |
390 | after the first line. */ | 391 | after the first line. */ |
@@ -392,28 +393,25 @@ void get_src_version(const char *modname, char sum[], unsigned sumlen) | |||
392 | basename = strrchr(modname, '/') + 1; | 393 | basename = strrchr(modname, '/') + 1; |
393 | else | 394 | else |
394 | basename = modname; | 395 | basename = modname; |
395 | sprintf(filelist, "%s/%.*s.mod", getenv("MODVERDIR"), | 396 | sprintf(filelist, "%s/%.*s.mod", modverdir, |
396 | (int) strlen(basename) - 2, basename); | 397 | (int) strlen(basename) - 2, basename); |
397 | 398 | ||
398 | file = grab_file(filelist, &len); | 399 | file = grab_file(filelist, &len); |
399 | if (!file) { | 400 | if (!file) { |
400 | fprintf(stderr, "Warning: could not find versions for %s\n", | 401 | warn("could not find versions for %s\n", filelist); |
401 | filelist); | ||
402 | return; | 402 | return; |
403 | } | 403 | } |
404 | 404 | ||
405 | sources = strchr(file, '\n'); | 405 | sources = strchr(file, '\n'); |
406 | if (!sources) { | 406 | if (!sources) { |
407 | fprintf(stderr, "Warning: malformed versions file for %s\n", | 407 | warn("malformed versions file for %s\n", modname); |
408 | modname); | ||
409 | goto release; | 408 | goto release; |
410 | } | 409 | } |
411 | 410 | ||
412 | sources++; | 411 | sources++; |
413 | end = strchr(sources, '\n'); | 412 | end = strchr(sources, '\n'); |
414 | if (!end) { | 413 | if (!end) { |
415 | fprintf(stderr, "Warning: bad ending versions file for %s\n", | 414 | warn("bad ending versions file for %s\n", modname); |
416 | modname); | ||
417 | goto release; | 415 | goto release; |
418 | } | 416 | } |
419 | *end = '\0'; | 417 | *end = '\0'; |
@@ -438,19 +436,19 @@ static void write_version(const char *filename, const char *sum, | |||
438 | 436 | ||
439 | fd = open(filename, O_RDWR); | 437 | fd = open(filename, O_RDWR); |
440 | if (fd < 0) { | 438 | if (fd < 0) { |
441 | fprintf(stderr, "Warning: changing sum in %s failed: %s\n", | 439 | warn("changing sum in %s failed: %s\n", |
442 | filename, strerror(errno)); | 440 | filename, strerror(errno)); |
443 | return; | 441 | return; |
444 | } | 442 | } |
445 | 443 | ||
446 | if (lseek(fd, offset, SEEK_SET) == (off_t)-1) { | 444 | if (lseek(fd, offset, SEEK_SET) == (off_t)-1) { |
447 | fprintf(stderr, "Warning: changing sum in %s:%lu failed: %s\n", | 445 | warn("changing sum in %s:%lu failed: %s\n", |
448 | filename, offset, strerror(errno)); | 446 | filename, offset, strerror(errno)); |
449 | goto out; | 447 | goto out; |
450 | } | 448 | } |
451 | 449 | ||
452 | if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) { | 450 | if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) { |
453 | fprintf(stderr, "Warning: writing sum in %s failed: %s\n", | 451 | warn("writing sum in %s failed: %s\n", |
454 | filename, strerror(errno)); | 452 | filename, strerror(errno)); |
455 | goto out; | 453 | goto out; |
456 | } | 454 | } |