scripts: utils: migrate_sys_init: handle empty line after ARG_UNUSED

The script left empty lines below ARG_UNUSED. After this patch,

```c
static int f(const struct device *dev)
{
	ARG_UNUSED(dev);

	/* code */
	...
}
```

will become:

```c
static int f(void)
{
	/* code */
	...
}
```

instead of:

```c
static int f(void)
{

	/* code */
	...
}
```

Fixes #56954

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
Gerard Marull-Paretas 2023-04-25 13:04:26 +02:00 committed by Carles Cufí
commit a01d40f604

View file

@ -45,6 +45,7 @@ def update_sys_init(project, dry_run):
arg = None
content = ""
update = False
unused = False
for line in lines:
m = re.match(
r"(.*)int ("
@ -60,8 +61,14 @@ def update_sys_init(project, dry_run):
m = re.match(r"^\s?ARG_UNUSED\(" + arg + r"\);.*$", line)
if m:
arg = None
unused = True
else:
content += line
elif unused:
m = re.match(r"^\s?\n$", line)
if not m:
content += line
unused = False
else:
content += line