diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-11-20 23:40:44 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-11-22 10:54:38 +0100 |
commit | baaa35ad706419ae5aacc11d2bece5bd8b73ee42 (patch) | |
tree | bb4b9c576fc56b3237d59e959ded7c245917fcd7 /src/udev/mtd_probe/probe_smartmedia.c | |
parent | 52d86690d68779b120a4380f7cc740825827fb0d (diff) | |
download | systemd-baaa35ad706419ae5aacc11d2bece5bd8b73ee42.tar.gz |
coccinelle: make use of SYNTHETIC_ERRNO
Ideally, coccinelle would strip unnecessary braces too. But I do not see any
option in coccinelle for this, so instead, I edited the patch text using
search&replace to remove the braces. Unfortunately this is not fully automatic,
in particular it didn't deal well with if-else-if-else blocks and ifdefs, so
there is an increased likelikehood be some bugs in such spots.
I also removed part of the patch that coccinelle generated for udev, where we
returns -1 for failure. This should be fixed independently.
Diffstat (limited to 'src/udev/mtd_probe/probe_smartmedia.c')
-rw-r--r-- | src/udev/mtd_probe/probe_smartmedia.c | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/src/udev/mtd_probe/probe_smartmedia.c b/src/udev/mtd_probe/probe_smartmedia.c index 099809da1b..f8e1b140f5 100644 --- a/src/udev/mtd_probe/probe_smartmedia.c +++ b/src/udev/mtd_probe/probe_smartmedia.c @@ -49,19 +49,17 @@ int probe_smart_media(int mtd_fd, mtd_info_t* info) { if (!cis_buffer) return log_oom(); - if (info->type != MTD_NANDFLASH) { - log_debug("Not marked MTD_NANDFLASH."); - return -EINVAL; - } + if (info->type != MTD_NANDFLASH) + return log_debug_errno(SYNTHETIC_ERRNO(EINVAL), + "Not marked MTD_NANDFLASH."); sector_size = info->writesize; block_size = info->erasesize; size_in_megs = info->size / (1024 * 1024); - if (!IN_SET(sector_size, SM_SECTOR_SIZE, SM_SMALL_PAGE)) { - log_debug("Unexpected sector size: %i", sector_size); - return -EINVAL; - } + if (!IN_SET(sector_size, SM_SECTOR_SIZE, SM_SMALL_PAGE)) + return log_debug_errno(SYNTHETIC_ERRNO(EINVAL), + "Unexpected sector size: %i", sector_size); switch(size_in_megs) { case 1: @@ -85,16 +83,14 @@ int probe_smart_media(int mtd_fd, mtd_info_t* info) { } } - if (!cis_found) { - log_debug("CIS not found"); - return -EINVAL; - } + if (!cis_found) + return log_debug_errno(SYNTHETIC_ERRNO(EINVAL), + "CIS not found"); if (memcmp(cis_buffer, cis_signature, sizeof(cis_signature)) != 0 && - memcmp(cis_buffer + SM_SMALL_PAGE, cis_signature, sizeof(cis_signature)) != 0) { - log_debug("CIS signature didn't match"); - return -EINVAL; - } + memcmp(cis_buffer + SM_SMALL_PAGE, cis_signature, sizeof(cis_signature)) != 0) + return log_debug_errno(SYNTHETIC_ERRNO(EINVAL), + "CIS signature didn't match"); printf("MTD_FTL=smartmedia\n"); return 0; |