Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions libpdbg/dtb.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ static bool get_chipid(uint32_t *chip_id)
cfam_id_file = fopen(path, "r");
free(path);
if (!cfam_id_file) {
pdbg_log(PDBG_ERROR, "Unable to open CFAM ID file\n");
pdbg_log(PDBG_ERROR, "Unable to open CFAM ID file errno: %d\n",errno);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After free() errno may have changed. It might be better to check before free() or save the errno.

return false;
}

Expand Down Expand Up @@ -512,7 +512,7 @@ static void mmap_dtb(const char *file, bool readonly, struct pdbg_mfile *mfile)
else
fd = open(file, O_RDWR);
if (fd < 0) {
pdbg_log(PDBG_ERROR, "Unable to open dtb file '%s'\n", file);
pdbg_log(PDBG_ERROR, "Unable to open dtb file '%s' errno: %d\n", file, errno);
return;
}

Expand Down
8 changes: 4 additions & 4 deletions libpdbg/kernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,14 @@ static void kernel_fsi_scan_devices(void)

fd = open(path, O_WRONLY | O_SYNC);
if (fd < 0) {
PR_ERROR("Unable to open %s\n", path);
PR_ERROR("Unable to open %s errno: %d\n", path, errno);
free(path);
return;
}

rc = write(fd, &one, sizeof(one));
if (rc < 0)
PR_ERROR("Unable to write to %s\n", path);
PR_ERROR("Unable to write to %s errno: %d\n", path, errno);

free(path);
close(fd);
Expand Down Expand Up @@ -186,7 +186,7 @@ int kernel_fsi_probe(struct pdbg_target *target)
}
}

PR_INFO("Unable to open %s\n", path);
PR_INFO("Unable to open %s, errno: %d \n", path, errno);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is far away from open failure and error prone. Always better to have it close to failure or save the errno.

free(path);
return -1;
}
Expand Down Expand Up @@ -264,7 +264,7 @@ static int kernel_pib_probe(struct pdbg_target *target)

pib->fd = open(scom_path, O_RDWR | O_SYNC);
if (pib->fd < 0) {
PR_INFO("Unable to open %s\n", scom_path);
PR_INFO("Unable to open %s errno: %d\n", scom_path, errno);
return -1;
}

Expand Down
2 changes: 1 addition & 1 deletion libpdbg/sbefifo.c
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,7 @@ static int sbefifo_probe(struct pdbg_target *target)

rc = sbefifo_connect(sbefifo_path, proc, &sf->sf_ctx);
if (rc) {
PR_ERROR("Unable to open sbefifo driver %s\n", sbefifo_path);
PR_ERROR("Unable to open sbefifo driver %s errno: %d\n", sbefifo_path, rc);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to print rc here as we don't know when errno was set in the sbefifo_connect(), right?

return rc;
}

Expand Down