fb50a1cca3a117bb964c43196671142484b13bf9 braney Fri Jun 12 12:10:47 2026 -0700 lib jkOwnLib hg/lib: fix warnings exposed by -O3 build At -O3 GCC does more inlining and interprocedural range analysis, which surfaces several warnings that -O -g never triggered. With -Werror these break the build, so fix them ahead of switching the default to -O3. - bamFile.c: move setenv() into the else of its NULL guard so it is not reachable with a NULL argument (-Wnonnull, seen via inlining of bamFetch). - basicBed.c, wormdna.c, bedDetail.c, customFactory.c, hdb.c, qaSeq.c: replace strncpy() with safecpy() where the result must be terminated (-Wstringop-truncation). - htmshell.c: use memcpy() for the intentional exact-length, non-terminated copy (-Wstringop-truncation). - obscure.c: compute the comma groups in sprintLongWithCommas() with % 1000 so the compiler can see each %03lld argument is bounded (-Wformat-overflow). - crudeali.c: do the endian type-pun through a union so strict-aliasing analysis no longer reports the value as uninitialized (-Wuninitialized). - jksql.c: wrap a possibly-NULL database name in naForNull() before passing it to %s (-Wformat-overflow). refs #37761 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> diff --git src/hg/lib/jksql.c src/hg/lib/jksql.c index e2ca3dff240..7b576592618 100644 --- src/hg/lib/jksql.c +++ src/hg/lib/jksql.c @@ -408,31 +408,31 @@ return NULL; char *failoverProfName = catTwoStrings(failoverProfPrefix, sp->name); struct sqlProfile *failoverProf = sqlProfileGet(failoverProfName, database); freez(&failoverProfName); return failoverProf; } static struct sqlProfile* sqlProfileMustGet(char *profileName, char *database) /* lookup a profile using the profile resolution algorithm or die trying */ { struct sqlProfile* sp = sqlProfileGet(profileName, database); if (sp == NULL) { if (profileName == NULL) errAbort("can't find mysql connection info for database '%s' in hg.conf or ~/.hg.conf, should have a default profile named 'db', so values for at least db.host, " - "db.user and db.password. See http://genomewiki.ucsc.edu/index.php/Hg.conf", database); + "db.user and db.password. See http://genomewiki.ucsc.edu/index.php/Hg.conf", naForNull(database)); else if (sameWord(profileName, "backupcentral")) errAbort("can't find profile '%s.*' in hg.conf. This error most likely indicates that the " "Genome Browser could not connect to MySQL/MariaDB. Either the databases server is not running" "or the database connection socket indicated in hg.conf is not the one used by your server.", profileName); else if (database == NULL) errAbort("can't find profile '%s.*' in hg.conf", profileName); else errAbort("can't find profile '%s.*' for database '%s.*' in hg.conf", profileName, database); } return sp; } struct slName* sqlProfileGetNames() /* Get a list of all profile names. slFreeList result when done */