Skip to content

x/sys/unix: TIPC_WAIT_FOREVER isn't usable in TIPCSubscr.Timeout #34310

@mischief

Description

@mischief

What version of Go are you using (go version)?

$ go version
go version go1.13rc2 linux/amd64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/mischief/.cache/go-build"
GOENV="/home/mischief/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/mischief/code/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/mischief/src/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/mischief/src/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build480716661=/tmp/go-build -gno-record-gcc-switches"

What did you do?

package main

import (
	"fmt"

	"golang.org/x/sys/unix"
)

func main() {
	seq := unix.TIPCServiceRange{
		Type:  999,
		Lower: 0,
		Upper: ^uint32(0),
	}
	sub := &unix.TIPCSubscr{
		Seq:     seq,
		Timeout: unix.TIPC_WAIT_FOREVER,
		Filter:  unix.TIPC_SUB_PORTS,
	}
	fmt.Println(sub)
}

What did you expect to see?

the subscription is printed.

What did you see instead?

./f.go:17:3: constant -1 overflows uint32

TIPC_WAIT_FOREVER is a sentinel value to make a subscription never time out (see here).

its value is currently const TIPC_WAIT_FOREVER = -0x1. the kernel headers define it as a macro ((~0)). however, the TIPCSubscr.Timeout field is a uint32, so assignment doesn't work.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions