From 38f1ffbd30e38b3215fa81114230ae2948dca8dc Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Mon, 2 Dec 2024 10:57:36 +0100 Subject: pkg/declextract: refactor netlink generation Emit all information related to a single netlink family close to each other. Previously we emitted them scattered and grouped by info type. That was both inconvinient to emit and inconvinient to read. NFC. --- pkg/declextract/serialization.go | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) (limited to 'pkg/declextract/serialization.go') diff --git a/pkg/declextract/serialization.go b/pkg/declextract/serialization.go index c737a675c..1bc82a86b 100644 --- a/pkg/declextract/serialization.go +++ b/pkg/declextract/serialization.go @@ -14,8 +14,8 @@ func (ctx *context) serialize() { ctx.fmt(header) ctx.serializeIncludes() ctx.serializeEnums() - ctx.emitNetlinkTypes() ctx.serializeSyscalls() + ctx.serializeNetlink() ctx.serializeStructs() ctx.serializeDefines() } @@ -47,28 +47,12 @@ func (ctx *context) serializeDefines() { } func (ctx *context) serializeSyscalls() { - printedGetFamily, printedSendmsg := false, false for _, call := range ctx.Syscalls { ctx.fmt("%v(", call.Func) for i, arg := range call.Args { ctx.fmt("%v%v %v", comma(i), arg.Name, arg.syzType) } ctx.fmt(")\n") - - if call.Func == "syslog$auto" { - printedGetFamily = true - ctx.emitNetlinkGetFamily() - } - if call.Func == "sendmsg$auto" { - printedSendmsg = true - ctx.emitNetlinkSendmsgs() - } - } - if !printedGetFamily { - ctx.emitNetlinkGetFamily() - } - if !printedSendmsg { - ctx.emitNetlinkSendmsgs() } ctx.fmt("\n") } @@ -102,9 +86,6 @@ func (ctx *context) serializeStructs() { if str.Align != 0 { attrs = append(attrs, fmt.Sprintf("align[%v]", str.Align)) } - if str.isVarlen { - attrs = append(attrs, "varlen") - } if len(attrs) != 0 { ctx.fmt(" [%v]", strings.Join(attrs, ", ")) } -- cgit mrf-deployment