Declare const char * pointers as such

This commit is contained in:
Stefan Rueger
2026-07-11 12:11:28 +01:00
parent eb2e73241a
commit 65dd419fdd
3 changed files with 5 additions and 6 deletions

View File

@@ -591,7 +591,7 @@ const char *str_plural(int x) {
static const char *str_filename(const char *fn, const char *stdname) {
if(!fn)
fn = "???";
char *p1 = strrchr(fn, '/'), *p2 = strrchr(fn, '\\');
const char *p1 = strrchr(fn, '/'), *p2 = strrchr(fn, '\\');
return str_eq(fn, "-")? stdname: str_starts(fn, "/dev/")? fn: p1? p1 + 1: p2? p2 + 1: fn;
}

View File

@@ -425,7 +425,7 @@ static int check_for_port_argument_match(const char *port, const char *bus,
if(str_casestarts(port, "usb:")) {
port += 4;
char *dev_name = strchr(port, ':');
const char *dev_name = strchr(port, ':');
if(dev_name) // Compare with busdir:devicefile
return str_busdev_eq(port, bus) && str_busdev_eq(dev_name+1, device);

View File

@@ -968,7 +968,7 @@ static int xbeedev_open(const char *port, union pinfo pinfo, union filedescripto
*
* ... for a direct connection.
*/
char *ttySeparator = strchr(port, '@');
const char *ttySeparator = strchr(port, '@');
if(ttySeparator == NULL) {
pmsg_error("XBee: bad port syntax, require <xbee-address>@<serial-device>\n");
@@ -979,7 +979,7 @@ static int xbeedev_open(const char *port, union pinfo pinfo, union filedescripto
XBeeBootSessionInit(xbs);
char *tty = &ttySeparator[1];
const char *tty = ttySeparator + 1;
if(ttySeparator == port) {
// Direct connection
@@ -1073,8 +1073,7 @@ static int xbeedev_open(const char *port, union pinfo pinfo, union filedescripto
pmsg_notice("baud %ld\n", (long) pinfo.serialinfo.baud);
{
const int rc = xbs->serialDevice->open(tty, pinfo,
&xbs->serialDescriptor);
const int rc = xbs->serialDevice->open(tty, pinfo, &xbs->serialDescriptor);
if(rc < 0) {
mmt_free(xbs);