![](https://secure.gravatar.com/avatar/5634a99cd64dd70d4a6692c3031a1284.jpg?s=120&d=mm&r=g)
Raymond Toy pushed to branch issue-120-software-type-in-c at cmucl / cmucl Commits: 51d4f25b by Raymond Toy at 2022-09-02T16:00:01-07:00 Simplify code and use strdup to copy the strings Reorder the code for os_software_version to keep all the UNAME_RELEASE_AND_VERSION code together. When UNAME_RELEASE_AND_VERSION is not set, use strdup to copy the release. In os_software_type, use strdup to copy the OS name, instead of malloc+strcpy. - - - - - 1 changed file: - src/lisp/os-common.c Changes: ===================================== src/lisp/os-common.c ===================================== @@ -740,19 +740,15 @@ os_software_version() int version_length; #if defined(UNAME_RELEASE_AND_VERSION) version_length = strlen(uts.release) + strlen(uts.version) + 2; -#else - version_length = strlen(uts.version) + 1; -#endif version = malloc(version_length); if (version) { -#if defined(UNAME_RELEASE_AND_VERSION) strcpy(version, uts.release); strcat(version, " "); strcat(version, uts.version); + } #else - strcpy(version, uts.version); + version = strdup(uts.version); #endif - } } return version; @@ -768,10 +764,7 @@ os_software_type() status = uname(&uts); if (status == 0) { - os_name = malloc(strlen(uts.sysname) + 1); - if (os_name) { - strcpy(os_name, uts.sysname); - } + os_name = strdup(uts.sysname); } return os_name; View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/51d4f25b5c61298d978e7df6... -- View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/51d4f25b5c61298d978e7df6... You're receiving this email because of your account on gitlab.common-lisp.net.