fix new compiler warnings
authorLuca Boccassi <bluca@debian.org>
Wed, 13 Nov 2024 23:04:09 +0000 (00:04 +0100)
committerAndreas Beckmann <anbe@debian.org>
Wed, 13 Nov 2024 23:04:09 +0000 (00:04 +0100)
Forwarded: https://github.com/Bumblebee-Project/Bumblebee/pull/1071

Gbp-Pq: Name compiler-warnings.patch

src/bbsecondary.c
src/pci.c

index 11520b8157bd81dd44fe38e11ba8dae25b428810..c71dc3b4f58918aefdc26d1be474d42cef1ab0dc 100644 (file)
@@ -139,10 +139,10 @@ bool start_secondary(bool need_secondary) {
     return true;
   //no problems, start X if not started yet
   if (!bb_is_running(bb_status.x_pid)) {
-    char pci_id[13];
+    char pci_id[16];
     static char *x_conf_file;
     // 0-255 bus, 0-31 slot, 0-7 func
-    snprintf(pci_id, 13, "PCI:%03d:%02d:%o", pci_bus_id_discrete->bus,
+    snprintf(pci_id, 16, "PCI:%03d:%02d:%o", pci_bus_id_discrete->bus,
             pci_bus_id_discrete->slot, pci_bus_id_discrete->func);
     if (!x_conf_file) {
       x_conf_file = xorg_path_w_driver(bb_config.x_conf_file, bb_config.driver);
index d26c24a20a19f3f8bf296e7d52c29944125ef7e3..fa77fffa61a855ce695ce4be2a01ad8c1e0ac4c2 100644 (file)
--- a/src/pci.c
+++ b/src/pci.c
@@ -54,7 +54,7 @@ int pci_parse_bus_id(struct pci_bus_id *dest, int bus_id_numeric) {
  */
 int pci_get_class(struct pci_bus_id *bus_id) {
   /* the Bus ID is always of fixed length */
-  char class_path[40];
+  char class_path[42];
   FILE *fp;
 
   snprintf(class_path, sizeof class_path,
@@ -133,7 +133,7 @@ struct pci_bus_id *pci_find_gfx_by_vendor(unsigned int vendor_id, unsigned int i
  * buffer was too small) or 0 on error
  */
 size_t pci_get_driver(char *dest, struct pci_bus_id *bus_id, size_t len) {
-  char path[1024];
+  char path[1024], resolved_path[1024];
   ssize_t read_bytes;
   char *name;
 
@@ -145,16 +145,16 @@ size_t pci_get_driver(char *dest, struct pci_bus_id *bus_id, size_t len) {
   /* the path to the driver if one is loaded */
   snprintf(path, sizeof path,  "/sys/bus/pci/devices/0000:%02x:%02x.%o/driver",
           bus_id->bus, bus_id->slot, bus_id->func);
-  read_bytes = readlink(path, path, sizeof(path) - 1);
+  read_bytes = readlink(path, resolved_path, sizeof(resolved_path) - 1);
   if (read_bytes < 0) {
     /* error, assume that the driver is not loaded */
     return 0;
   }
 
   /* readlink does not append a NULL according to the manpage */
-  path[read_bytes] = 0;
+  resolved_path[read_bytes] = 0;
 
-  name = basename(path);
+  name = basename(resolved_path);
   /* save the name if a valid destination and buffer size was given */
   if (dest && len > 0) {
     strncpy(dest, name, len - 1);
@@ -172,7 +172,7 @@ size_t pci_get_driver(char *dest, struct pci_bus_id *bus_id, size_t len) {
  * @return a file handle on success, or NULL on failure
  */
 static int pci_config_open(struct pci_bus_id *bus_id, mode_t mode) {
-  char config_path[41];
+  char config_path[43];
 
   snprintf(config_path, sizeof config_path,
           "/sys/bus/pci/devices/0000:%02x:%02x.%o/config", bus_id->bus,