On Sunday, 21 January 2018 16:23:56 GMT Ralph Corderoy wrote: > `k' is already a `const char *' so the cast to the same thing looks > redundant. Because that parameter is a const, I think the first version > is picked, it returns a `const char *', but it's being assigned to `p' > that's a non-const `char *'. > > Looking at the use of `p', I suggest making that a const too.
I didn't spot this yesterday, but that won't work because p is used as a variable within that function. Here is the full code: //Retrieve the subdevice value, whith comes after the capital D //in the device name, (i.e. pcmC0D1). int GetDValue(const char *k) { char *p = strrchr((char *)k, 'D'); if (!p) { return -1; } p++; int d = strtol(p, NULL, 0); if (d < 0 || d > 32) return 0; return d; } -- Terry Coles -- Next meeting: Bournemouth, Tuesday, 2018-02-06 20:00 Meets, Mailing list, IRC, LinkedIn, ... http://dorset.lug.org.uk/ New thread: mailto:dorset@mailman.lug.org.uk / CHECK IF YOU'RE REPLYING Reporting bugs well: http://goo.gl/4Xue / TO THE LIST OR THE AUTHOR