diff mbox series

multipath-tools: fix an assignment ambiguity

Message ID 20240122224206.141196-1-xose.vazquez@gmail.com (mailing list archive)
State Not Applicable, archived
Delegated to: christophe varoqui
Headers show
Series multipath-tools: fix an assignment ambiguity | expand

Commit Message

Xose Vazquez Perez Jan. 22, 2024, 10:42 p.m. UTC
spotted by indent:
./kpartx/gpt.c:623: Warning:old style assignment ambiguity in "=-". Assuming "= -"

Cc: Martin Wilck <mwilck@suse.com>
Cc: Benjamin Marzinski <bmarzins@redhat.com>
Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: DM-DEVEL ML <dm-devel@lists.linux.dev>
Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
---
 kpartx/gpt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Martin Wilck Jan. 23, 2024, 7:49 a.m. UTC | #1
On Mon, 2024-01-22 at 23:42 +0100, Xose Vazquez Perez wrote:
> spotted by indent:
> ./kpartx/gpt.c:623: Warning:old style assignment ambiguity in "=-".
> Assuming "= -"
> 
> Cc: Martin Wilck <mwilck@suse.com>
> Cc: Benjamin Marzinski <bmarzins@redhat.com>
> Cc: Christophe Varoqui <christophe.varoqui@opensvc.com>
> Cc: DM-DEVEL ML <dm-devel@lists.linux.dev>
> Signed-off-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
> ---
>  kpartx/gpt.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

This "ambiguity" must relate to some ancient compilers accepting '=-'
as an alias for '-='. That must predate K&R 1st edition (1978), which
clearly defines the assignment operator syntax for operator 'op' as
'op=' [1].

But well, it's always good to eliminate warnings, so

Reviewed-by: Martin Wilck <mwilck@suse.com>

[1] https://www.academia.edu/34487452/First_edition_of_c_by_dennis_ritche
diff mbox series

Patch

diff --git a/kpartx/gpt.c b/kpartx/gpt.c
index 47d8743e..fbf6ae22 100644
--- a/kpartx/gpt.c
+++ b/kpartx/gpt.c
@@ -606,7 +606,7 @@  read_gpt_pt (int fd, __attribute__((unused)) struct slice all,
 	gpt_entry *ptes = NULL;
 	unsigned int i;
 	int n = 0;
-	int last_used_index=-1;
+	int last_used_index = -1;
 	int sector_size_mul = get_sector_size(fd)/512;
 
 	if (!find_valid_gpt (fd, &gpt, &ptes) || !gpt || !ptes) {