From a0fd2f2bbd815306c6b4b5350d5751da9ece2e7e Mon Sep 17 00:00:00 2001 From: Marco Nelissen Date: Sat, 2 Nov 2024 16:29:50 -0700 Subject: [PATCH] Reduce logging Update the various mtp_get_storage_* functions so that they only print one debug line per call instead of two. --- src/mtp.c | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/src/mtp.c b/src/mtp.c index 8bf523a..ef1049c 100644 --- a/src/mtp.c +++ b/src/mtp.c @@ -777,8 +777,6 @@ uint32_t mtp_get_storage_id_by_name(mtp_ctx * ctx, char * name) { int i; - PRINT_DEBUG("mtp_get_storage_id_by_name : %s", name ); - i = 0; while(i < MAX_STORAGE_NB) { @@ -786,7 +784,8 @@ uint32_t mtp_get_storage_id_by_name(mtp_ctx * ctx, char * name) { if( !strcmp(ctx->storages[i].description, name ) ) { - PRINT_DEBUG("mtp_get_storage_id_by_name : %s -> %.8X", + PRINT_DEBUG("%s : %s -> %.8X", + __func__, ctx->storages[i].root_path, ctx->storages[i].storage_id); @@ -796,6 +795,8 @@ uint32_t mtp_get_storage_id_by_name(mtp_ctx * ctx, char * name) i++; } + PRINT_DEBUG("%s : '%s' not found", __func__, name ); + return 0xFFFFFFFF; } @@ -803,8 +804,6 @@ int mtp_get_storage_index_by_name(mtp_ctx * ctx, char * name) { int i; - PRINT_DEBUG("mtp_get_storage_index_by_name : %s", name ); - i = 0; while(i < MAX_STORAGE_NB) { @@ -812,7 +811,8 @@ int mtp_get_storage_index_by_name(mtp_ctx * ctx, char * name) { if( !strcmp(ctx->storages[i].description, name ) ) { - PRINT_DEBUG("mtp_get_storage_index_by_name : %s -> %.8X", + PRINT_DEBUG("%s : %s -> %.8X", + __func__, ctx->storages[i].root_path, i); @@ -822,6 +822,8 @@ int mtp_get_storage_index_by_name(mtp_ctx * ctx, char * name) i++; } + PRINT_DEBUG("%s : '%s' not found", __func__, name ); + return -1; } @@ -829,8 +831,6 @@ int mtp_get_storage_index_by_id(mtp_ctx * ctx, uint32_t storage_id) { int i; - PRINT_DEBUG("mtp_get_storage_index_by_id : 0x%X", storage_id ); - i = 0; while(i < MAX_STORAGE_NB) { @@ -838,7 +838,8 @@ int mtp_get_storage_index_by_id(mtp_ctx * ctx, uint32_t storage_id) { if( ctx->storages[i].storage_id == storage_id ) { - PRINT_DEBUG("mtp_get_storage_index_by_id : %.8X -> %d", + PRINT_DEBUG("%s : %.8X -> %d", + __func__, storage_id, i ); return i; @@ -847,6 +848,8 @@ int mtp_get_storage_index_by_id(mtp_ctx * ctx, uint32_t storage_id) i++; } + PRINT_DEBUG("%s : 0x%X not found", __func__, storage_id ); + return -1; } @@ -854,8 +857,6 @@ char * mtp_get_storage_root(mtp_ctx * ctx, uint32_t storage_id) { int i; - PRINT_DEBUG("mtp_get_storage_root : %.8X", storage_id ); - i = 0; while(i < MAX_STORAGE_NB) { @@ -863,7 +864,8 @@ char * mtp_get_storage_root(mtp_ctx * ctx, uint32_t storage_id) { if( ctx->storages[i].storage_id == storage_id ) { - PRINT_DEBUG("mtp_get_storage_root : %.8X -> %s", + PRINT_DEBUG("%s : %.8X -> %s", + __func__, storage_id, ctx->storages[i].root_path ); return ctx->storages[i].root_path; @@ -872,6 +874,7 @@ char * mtp_get_storage_root(mtp_ctx * ctx, uint32_t storage_id) i++; } + PRINT_DEBUG("%s : %.8X not found", __func__, storage_id ); return NULL; } @@ -879,8 +882,6 @@ char * mtp_get_storage_description(mtp_ctx * ctx, uint32_t storage_id) { int i; - PRINT_DEBUG("mtp_get_storage_description : %.8X", storage_id ); - i = 0; while(i < MAX_STORAGE_NB) { @@ -888,7 +889,8 @@ char * mtp_get_storage_description(mtp_ctx * ctx, uint32_t storage_id) { if( ctx->storages[i].storage_id == storage_id ) { - PRINT_DEBUG("mtp_get_storage_description : %.8X -> %s", + PRINT_DEBUG("%s : %.8X -> %s", + __func__, storage_id, ctx->storages[i].description ); return ctx->storages[i].description; @@ -897,6 +899,8 @@ char * mtp_get_storage_description(mtp_ctx * ctx, uint32_t storage_id) i++; } + PRINT_DEBUG("%s : %.8X not found", __func__, storage_id ); + return NULL; } @@ -904,8 +908,6 @@ uint32_t mtp_get_storage_flags(mtp_ctx * ctx, uint32_t storage_id) { int i; - PRINT_DEBUG("mtp_get_storage_flags : %.8X", storage_id ); - i = 0; while(i < MAX_STORAGE_NB) { @@ -913,7 +915,8 @@ uint32_t mtp_get_storage_flags(mtp_ctx * ctx, uint32_t storage_id) { if( ctx->storages[i].storage_id == storage_id ) { - PRINT_DEBUG("mtp_get_storage_flags : %.8X -> 0x%.8X", + PRINT_DEBUG("%s : %.8X -> 0x%.8X", + __func__, storage_id, ctx->storages[i].flags ); return ctx->storages[i].flags; @@ -922,6 +925,8 @@ uint32_t mtp_get_storage_flags(mtp_ctx * ctx, uint32_t storage_id) i++; } + PRINT_DEBUG("%s : %.8X not found", __func__, storage_id ); + return 0xFFFFFFFF; }