From 29741a6360155e88d4c8b569af0d5ea5cbd4d6aa Mon Sep 17 00:00:00 2001 From: nnposter Date: Thu, 4 Jul 2024 03:21:53 +0000 Subject: [PATCH] Avoid using hard-coded numerical codes. Replace repeated expression with a local variable --- nselib/mssql.lua | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/nselib/mssql.lua b/nselib/mssql.lua index b2662f10e..16cb4baf0 100644 --- a/nselib/mssql.lua +++ b/nselib/mssql.lua @@ -3134,12 +3134,13 @@ Helper = for i=1, #colinfo do local val - if ( ColumnData.Parse[colinfo[i].type] ) then - if not ( colinfo[i].type == 106 or colinfo[i].type == 108) then - pos, val = ColumnData.Parse[colinfo[i].type](data, pos) - else + local coltype = colinfo[i].type + if ( ColumnData.Parse[coltype] ) then + if coltype == DataTypes.DECIMALNTYPE or coltype == DataTypes.NUMERICNTYPE then -- decimal / numeric types need precision and scale passed. - pos, val = ColumnData.Parse[colinfo[i].type]( colinfo[i].precision, colinfo[i].scale, data, pos) + pos, val = ColumnData.Parse[coltype]( colinfo[i].precision, colinfo[i].scale, data, pos) + else + pos, val = ColumnData.Parse[coltype](data, pos) end if ( -1 == pos ) then @@ -3147,7 +3148,7 @@ Helper = end table.insert(columns, val) else - return false, ("unknown datatype=0x%X"):format(colinfo[i].type) + return false, ("unknown datatype=0x%X"):format(coltype) end end table.insert(rows, columns)