Symbols are not recognize linux driver - linux-kernel

I try to load a linux driver and I got this message :
# modprobe hci_uart
hci_uart: Unknown symbol hci_free_dev (err 0)
hci_uart: Unknown symbol hci_alloc_dev (err 0)
hci_uart: Unknown symbol bt_info (err 0)
hci_uart: Unknown symbol bt_err (err 0)
hci_uart: Unknown symbol hci_unregister_dev (err 0)
hci_uart: Unknown symbol hci_recv_frame (err 0)
hci_uart: Unknown symbol hci_register_dev (err 0)
hci_uart: Unknown symbol bt_warn (err 0)
hci_uart: Unknown symbol hci_free_dev (err 0)
hci_uart: Unknown symbol hci_alloc_dev (err 0)
hci_uart: Unknown symbol bt_info (err 0)
hci_uart: Unknown symbol bt_err (err 0)
hci_uart: Unknown symbol hci_unregister_dev (err 0)
hci_uart: Unknown symbol hci_recv_frame (err 0)
hci_uart: Unknown symbol hci_register_dev (err 0)
hci_uart: Unknown symbol bt_warn (err 0)
modprobe: can't load module hci_uart (kernel/drivers/bluetooth/bluetooth_uart_driver/hci_uart.ko): unknown symbol in module, or unknown parameter
The module is checked in linux-menuconfig (I use buildroot), I tried to load an other linux driver and I do not get this message.
Any idea.
Thank you very much.

I found out, there were a trouble dependencies, so from linux-menuconfig I added the dependencies needed. I checked the makefile to know which one I had to add.

Related

Execute the sqlite3 connector with golang in vscode. Met below error: collect2: error: ld returned 1 exit status

package main
import (
"database/sql"
"fmt"
"log"
"os"
_ "github.com/mattn/go-sqlite3"
)
type Users struct {
UserId, intUname string
}
func main() {
os.Remove("foo.db")
db, err := sql.Open("sqlite3", "foo.db")
if err != nil {
log.Fatal(err)
}
defer db.Close()
sql := `create table users (userId integer, uname text);`
db.Exec(sql)
sql = `insert into users(userId,uname) values(1,'Mike');`
db.Exec(sql)
sql = `insert into users(userId,uname) values(2,'John');`
db.Exec(sql)
rows, err := db.Query("select * from users")
if err != nil {
log.Fatal(err)
}
defer rows.Close()
var users []Users = make([]Users, 0)
for rows.Next() {
var u Users
rows.Scan(&u.UserId, &u.intUname)
users = append(users, u)
}
fmt.Println(users)
}
Above is my codes. Now I will run this file. Codes only connect to sqlite3 database, And execute some sql, No any else operate. I don't know why to happen this.
Met below error:
csccl25013> go run .
github.com/goproject/sqlite3
/nfs/site/disks/simcloud_zhoudo1x_002/go/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/nfs/site/itools/em64t_SLES12SP5/pkgs/gcc/4.7.2/.bin/../lib64/gcc/x86_64-suse-linux/4.7.2/../../../../x86_64-suse-linux/bin/ld: /tmp/go-link-322571714/000015.o(.text+0x63): unresolvable AWAVAUATUSH��h�*H�T$(���� relocation against symbol `stderr##GLIBC_2.2.5'
/nfs/site/itools/em64t_SLES12SP5/pkgs/gcc/4.7.2/.bin/../lib64/gcc/x86_64-suse-linux/4.7.2/../../../../x86_64-suse-linux/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
I don't know how to resolve this error. Please help me.
Expected Result:
Execute successful.
Connect sqlite3 normally.
The error indicates your Go toolchain is unable to build the CGO implementation for github.com/mattn/go-sqlite3 (eg, cross-compilation error).
If you are unable to troubleshoot your C compiler you could try importing modernc.org/sqlite and using the "sqlite" SQL driver instead. This is a pure Go conversion of Sqlite and avoids the need for the C compiler.

Go converting data to parquet

I am getting data from dynamodb and converting data to parquet files.
For the conversion to parquet files, I am using https://github.com/xitongsys/parquet-go library. But for some reason I am getting runtime error: invalid memory address or nil pointer dereference
I know this error means that a pointer is nil and I am trying to use it or dereference it.
Not sure why pw.WriteStop() is giving memory invalid error
code:
fw, err := local.NewLocalFileWriter(parquetFile)
if err != nil {
log.Errorf("local.NewLocalFileWriter() error - %s", err)
return err
}
pw, err := writer.NewParquetWriter(fw, new(Struct), int64(len(tenantList)))
if err != nil {
log.Errorf("writer.NewParquetWriter() error - %s", err)
return err
}
pw.RowGroupSize = 128 * 1024 * 1024 //128M
pw.CompressionType = parquet.CompressionCodec_SNAPPY
for _, data := range tenantList {
if err = pw.Write(data); err != nil {
return err
}
}
// this line gives memory invalid error
if err = pw.WriteStop(); err != nil {
return err
}
fw.Close()
The only error that I am getting is "runtime error: invalid memory address or nil pointer dereference". By printing statements in the "if" statements I found that invalid memory address is coming from "pw.WriteStop()"
Attaching a screenshot of the error; just to show that I am really getting only "runtime error: invalid memory address or nil pointer dereference"
I faced this too. Figured out that it is because I haven't specified 'type=BOOLEAN' for bool fields in the struct tags, e.g. parquet:"name=MyFieldName, type=BOOLEAN". For me, supplying BOOLEAN for bool, INT64 for int64 and UTF8 for string Go types worked.
Ideally the library should pick up data types automatically, but probably it's a feature not implemented, or it involves too much overhead and that's why intentionally not implemented.

What is the correct format specifier to print error object in Go: %s or %v?

Here is my program.
package main
import (
"errors"
"fmt"
)
func main() {
a := -1
err := assertPositive(a)
fmt.Printf("error: %s; int: %d\n", err, a)
fmt.Printf("error: %v; int: %d\n", err, a)
}
func assertPositive(a int) error {
if a <= 0 {
return errors.New("Assertion failure")
}
return nil
}
Here is the output.
error: Assertion failure; int: -1
error: Assertion failure; int: -1
In this program, it makes no difference whether I use %s or %v to print
the error object.
I have two questions.
Is there any scenario while printing errors where it would make a
difference for %s and %v?
What is the correct format specifier to use in this case?
According to docs:
%v the value in a default format
...
%s the uninterpreted bytes of the string or slice
Also, more information about error:
The error type is an interface type. An error variable represents any
value that can describe itself as a string.
So, treat it as %s.

How come I get cannot use type *sql.Row as type error when doing err == sql.ErrNoRows

I was trying to follow the example in the answer given here:
Golang: How to check for empty array (array of struct)
on how to check if a database return is empty
So I have this:
err = db.QueryRow("SELECT FROM accounts WHERE steamid=?", steamid)
switch {
case err == sql.ErrNoRows:
case err != nil:
default:
//do stuff
}
But I get the error:
cannot use db.QueryRow("SELECT FROM accounts WHERE steamid=?", steamid) (type *sql.Row) as type error in assignment:
*sql.Row does not implement error (missing Error method)
Not sure why it worked in his example but not when I try to implement it. Thanks.
You've missed the Scan part of the example, which actually returns an error:
err := db.QueryRow("SELECT ...").Scan(&id, &secret, &shortname)

body.Read undefined (type *io.ReadCloser has no field or method Read)

I can't seem to solve this weird error. Here's my code:
resp, err := http.Get("example.com/my/text/file.conf")
...
err = parseEvent(eventchan, &resp.Body)
func parseEvent(eventchan chan Event, body *io.ReadCloser) error {
raw := make([]byte, 1024*1024*32, 1024*1024*32)
n, err := body.Read(raw)
And i get this strange error:
./igen.go:91: body.Read undefined (type *io.ReadCloser has no field or method Read)
Row 91 is the n, err := body.Read(raw) line above.
What did I miss? Golang.org tells me ReadCloser implements Reader, which has the Read(p []byte) (n int, err error) method that I'm trying to call.
your parameter is body *io.ReadCloser - meaning a pointer to an interface. ReadCloser, the interface, has Read(). Just change your function signature to:
func parseEvent(eventchan chan Event, body io.ReadCloser) error

Resources