Skip to content

Commit 2c9a2f6

Browse files
authored
Merge pull request #204 from darkonie/mnaboka/fix-previous
sdjournal: fix return values type
2 parents a63dfec + 73338e2 commit 2c9a2f6

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

sdjournal/journal.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -474,21 +474,21 @@ func (j *Journal) FlushMatches() {
474474
}
475475

476476
// Next advances the read pointer into the journal by one entry.
477-
func (j *Journal) Next() (int, error) {
477+
func (j *Journal) Next() (uint64, error) {
478478
sd_journal_next, err := getFunction("sd_journal_next")
479479
if err != nil {
480-
return -1, err
480+
return 0, err
481481
}
482482

483483
j.mu.Lock()
484484
r := C.my_sd_journal_next(sd_journal_next, j.cjournal)
485485
j.mu.Unlock()
486486

487487
if r < 0 {
488-
return int(r), fmt.Errorf("failed to iterate journal: %d", syscall.Errno(-r))
488+
return 0, fmt.Errorf("failed to iterate journal: %d", syscall.Errno(-r))
489489
}
490490

491-
return int(r), nil
491+
return uint64(r), nil
492492
}
493493

494494
// NextSkip advances the read pointer by multiple entries at once,
@@ -504,7 +504,7 @@ func (j *Journal) NextSkip(skip uint64) (uint64, error) {
504504
j.mu.Unlock()
505505

506506
if r < 0 {
507-
return uint64(r), fmt.Errorf("failed to iterate journal: %d", syscall.Errno(-r))
507+
return 0, fmt.Errorf("failed to iterate journal: %d", syscall.Errno(-r))
508508
}
509509

510510
return uint64(r), nil
@@ -522,7 +522,7 @@ func (j *Journal) Previous() (uint64, error) {
522522
j.mu.Unlock()
523523

524524
if r < 0 {
525-
return uint64(r), fmt.Errorf("failed to iterate journal: %d", syscall.Errno(-r))
525+
return 0, fmt.Errorf("failed to iterate journal: %d", syscall.Errno(-r))
526526
}
527527

528528
return uint64(r), nil
@@ -541,7 +541,7 @@ func (j *Journal) PreviousSkip(skip uint64) (uint64, error) {
541541
j.mu.Unlock()
542542

543543
if r < 0 {
544-
return uint64(r), fmt.Errorf("failed to iterate journal: %d", syscall.Errno(-r))
544+
return 0, fmt.Errorf("failed to iterate journal: %d", syscall.Errno(-r))
545545
}
546546

547547
return uint64(r), nil

sdjournal/read.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func (r *JournalReader) Read(b []byte) (int, error) {
121121
var err error
122122

123123
if r.msgReader == nil {
124-
var c int
124+
var c uint64
125125

126126
// Advance the journal cursor. It has to be called at least one time
127127
// before reading

0 commit comments

Comments
 (0)