aboutsummaryrefslogtreecommitdiff
path: root/sys/contrib/openzfs/module/lua
diff options
context:
space:
mode:
Diffstat (limited to 'sys/contrib/openzfs/module/lua')
-rw-r--r--sys/contrib/openzfs/module/lua/lobject.h21
-rw-r--r--sys/contrib/openzfs/module/lua/lstate.h2
-rw-r--r--sys/contrib/openzfs/module/lua/lstring.c2
-rw-r--r--sys/contrib/openzfs/module/lua/lstring.h2
4 files changed, 15 insertions, 12 deletions
diff --git a/sys/contrib/openzfs/module/lua/lobject.h b/sys/contrib/openzfs/module/lua/lobject.h
index b7c6b41ac7f4..06fdcdcbcb84 100644
--- a/sys/contrib/openzfs/module/lua/lobject.h
+++ b/sys/contrib/openzfs/module/lua/lobject.h
@@ -404,19 +404,22 @@ typedef TValue *StkId; /* index to stack elements */
/*
** Header for string value; string bytes follow the end of this structure
*/
-typedef union TString {
- L_Umaxalign dummy; /* ensures maximum alignment for strings */
- struct {
- CommonHeader;
- lu_byte extra; /* reserved words for short strings; "has hash" for longs */
- unsigned int hash;
- size_t len; /* number of characters in string */
- } tsv;
+typedef struct TString {
+ union {
+ L_Umaxalign dummy; /* ensures maximum alignment for strings */
+ struct {
+ CommonHeader;
+ lu_byte extra; /* reserved words for short strings; "has hash" for longs */
+ unsigned int hash;
+ size_t len; /* number of characters in string */
+ } tsv;
+ };
+ char contents[];
} TString;
/* get the actual string (array of bytes) from a TString */
-#define getstr(ts) cast(const char *, (ts) + 1)
+#define getstr(ts) ((ts)->contents)
/* get the actual string (array of bytes) from a Lua value */
#define svalue(o) getstr(rawtsvalue(o))
diff --git a/sys/contrib/openzfs/module/lua/lstate.h b/sys/contrib/openzfs/module/lua/lstate.h
index 75c6ceda6d33..c5fa59335a9b 100644
--- a/sys/contrib/openzfs/module/lua/lstate.h
+++ b/sys/contrib/openzfs/module/lua/lstate.h
@@ -185,7 +185,7 @@ struct lua_State {
*/
union GCObject {
GCheader gch; /* common header */
- union TString ts;
+ struct TString ts;
union Udata u;
union Closure cl;
struct Table h;
diff --git a/sys/contrib/openzfs/module/lua/lstring.c b/sys/contrib/openzfs/module/lua/lstring.c
index 15a73116bb77..149a4ffc5023 100644
--- a/sys/contrib/openzfs/module/lua/lstring.c
+++ b/sys/contrib/openzfs/module/lua/lstring.c
@@ -103,7 +103,7 @@ static TString *createstrobj (lua_State *L, const char *str, size_t l,
ts->tsv.len = l;
ts->tsv.hash = h;
ts->tsv.extra = 0;
- sbuf = (char *)(TString *)(ts + 1);
+ sbuf = ts->contents;
memcpy(sbuf, str, l*sizeof(char));
sbuf[l] = '\0'; /* ending 0 */
return ts;
diff --git a/sys/contrib/openzfs/module/lua/lstring.h b/sys/contrib/openzfs/module/lua/lstring.h
index 260e7f169bd0..257b384172ec 100644
--- a/sys/contrib/openzfs/module/lua/lstring.h
+++ b/sys/contrib/openzfs/module/lua/lstring.h
@@ -12,7 +12,7 @@
#include "lstate.h"
-#define sizestring(s) (sizeof(union TString)+((s)->len+1)*sizeof(char))
+#define sizestring(s) (sizeof(struct TString)+((s)->len+1)*sizeof(char))
#define sizeudata(u) (sizeof(union Udata)+(u)->len)