From patchwork Wed Jun 17 19:52:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 242583 List-Id: U-Boot discussion From: xypron.glpk at gmx.de (Heinrich Schuchardt) Date: Wed, 17 Jun 2020 21:52:45 +0200 Subject: [PATCH v4 2/2] log: use BIT() instead of 1 << In-Reply-To: <20200617195245.11530-1-xypron.glpk@gmx.de> References: <20200617195245.11530-1-xypron.glpk@gmx.de> Message-ID: <20200617195245.11530-3-xypron.glpk@gmx.de> Use the BIT() macro when creating a bitmask for the logging fields. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- v4: no change v3: new patch --- common/log_console.c | 14 +++++++------- common/log_syslog.c | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) -- 2.27.0 diff --git a/common/log_console.c b/common/log_console.c index 0b5b7089af..bb3f8464b9 100644 --- a/common/log_console.c +++ b/common/log_console.c @@ -25,18 +25,18 @@ static int log_console_emit(struct log_device *ldev, struct log_rec *rec) * - function is an identifier and ends with () * - message has a space before it unless it is on its own */ - if (fmt & (1 << LOGF_LEVEL)) + if (fmt & BIT(LOGF_LEVEL)) printf("%s.", log_get_level_name(rec->level)); - if (fmt & (1 << LOGF_CAT)) + if (fmt & BIT(LOGF_CAT)) printf("%s,", log_get_cat_name(rec->cat)); - if (fmt & (1 << LOGF_FILE)) + if (fmt & BIT(LOGF_FILE)) printf("%s:", rec->file); - if (fmt & (1 << LOGF_LINE)) + if (fmt & BIT(LOGF_LINE)) printf("%d-", rec->line); - if (fmt & (1 << LOGF_FUNC)) + if (fmt & BIT(LOGF_FUNC)) printf("%s()", rec->func); - if (fmt & (1 << LOGF_MSG)) - printf("%s%s", fmt != (1 << LOGF_MSG) ? " " : "", rec->msg); + if (fmt & BIT(LOGF_MSG)) + printf("%s%s", fmt != BIT(LOGF_MSG) ? " " : "", rec->msg); return 0; } diff --git a/common/log_syslog.c b/common/log_syslog.c index 698c585fa1..149ff5af31 100644 --- a/common/log_syslog.c +++ b/common/log_syslog.c @@ -82,21 +82,21 @@ static int log_syslog_emit(struct log_device *ldev, struct log_rec *rec) if (log_hostname) append(&ptr, msg_end, "%s ", log_hostname); append(&ptr, msg_end, "uboot: "); - if (fmt & (1 << LOGF_LEVEL)) + if (fmt & BIT(LOGF_LEVEL)) append(&ptr, msg_end, "%s.", log_get_level_name(rec->level)); - if (fmt & (1 << LOGF_CAT)) + if (fmt & BIT(LOGF_CAT)) append(&ptr, msg_end, "%s,", log_get_cat_name(rec->cat)); - if (fmt & (1 << LOGF_FILE)) + if (fmt & BIT(LOGF_FILE)) append(&ptr, msg_end, "%s:", rec->file); - if (fmt & (1 << LOGF_LINE)) + if (fmt & BIT(LOGF_LINE)) append(&ptr, msg_end, "%d-", rec->line); - if (fmt & (1 << LOGF_FUNC)) + if (fmt & BIT(LOGF_FUNC)) append(&ptr, msg_end, "%s()", rec->func); - if (fmt & (1 << LOGF_MSG)) + if (fmt & BIT(LOGF_MSG)) append(&ptr, msg_end, "%s%s", - fmt != (1 << LOGF_MSG) ? " " : "", rec->msg); + fmt != BIT(LOGF_MSG) ? " " : "", rec->msg); /* Consider trailing 0x00 */ ptr++;