Fix more warnings from static code analysis

This commit is contained in:
Daniel Poelzleithner 2022-11-11 15:27:21 +01:00
parent 945b57d8fb
commit 5096f27bbd
18 changed files with 43 additions and 34 deletions

View File

@ -592,6 +592,7 @@ rsync.prepare = function
crsync._computed = { true } crsync._computed = { true }
--- @type any
local computed = crsync._computed local computed = crsync._computed
local computedN = 2 local computedN = 2

View File

@ -13,6 +13,7 @@ then
error( 'default already loaded' ) error( 'default already loaded' )
end end
--- @diagnostic disable-next-line: lowercase-global
default = { } default = { }

View File

@ -15,12 +15,12 @@ settings {
-- for testing purposes. prefix can be used to slow commands down. -- for testing purposes. prefix can be used to slow commands down.
-- prefix = "sleep 5 && " -- prefix = "sleep 5 && "
-- --
prefix = "" local prefix = ""
----- -----
-- for testing purposes. uses bash command to hold local dirs in sync. -- for testing purposes. uses bash command to hold local dirs in sync.
-- --
bash = { local bash = {
delay = 0, delay = 0,
maxProcesses = 1, maxProcesses = 1,

View File

@ -7,7 +7,7 @@
----- -----
-- for testing purposes. just echos what is happening. -- for testing purposes. just echos what is happening.
-- --
echo = { local echo = {
maxProcesses = 1, maxProcesses = 1,
delay = 1, delay = 1,
onStartup = "/bin/echo telling about ^source", onStartup = "/bin/echo telling about ^source",

View File

@ -22,12 +22,12 @@
---- ----
-- forces this group. -- forces this group.
-- --
fgroup = "staff" local fgroup = "staff"
----- -----
-- script for all changes. -- script for all changes.
-- --
command = local command =
-- checks if the group is the one enforced and sets them if not -- checks if the group is the one enforced and sets them if not
[[ [[
perm=`stat -c %A ^sourcePathname` perm=`stat -c %A ^sourcePathname`
@ -59,13 +59,13 @@ fi
-- the carret as first char tells Lsycnd to call a shell altough it -- the carret as first char tells Lsycnd to call a shell altough it
-- starts with a slash otherwisw -- starts with a slash otherwisw
-- --
startup = local startup =
[[^/bin/chgrp -R ]]..fgroup..[[ ^source || /bin/true && [[^/bin/chgrp -R ]]..fgroup..[[ ^source || /bin/true &&
/bin/chmod -R g+rw ^source || /bin/true && /bin/chmod -R g+rw ^source || /bin/true &&
/usr/bin/find ^source -type d | xargs chmod g+x /usr/bin/find ^source -type d | xargs chmod g+x
]] ]]
gforce = { local gforce = {
maxProcesses = 99, maxProcesses = 99,
delay = 1, delay = 1,
onStartup = startup, onStartup = startup,

View File

@ -12,7 +12,7 @@
-- --
local formats = { jpg=true, gif=true, png=true, } local formats = { jpg=true, gif=true, png=true, }
convert = { local convert = {
delay = 0, delay = 0,
maxProcesses = 99, maxProcesses = 99,

View File

@ -19,7 +19,7 @@
-- --
-- Author: Daniel Miranda <danielkza2@gmail.com> -- Author: Daniel Miranda <danielkza2@gmail.com>
-- --
s3 = {} local s3 = {}
s3.checkgauge = { s3.checkgauge = {
onCreate = false, onCreate = false,

View File

@ -21,15 +21,16 @@ require("socket")
-- For demo reasons, do not detach -- For demo reasons, do not detach
settings.nodaemon = true settings.nodaemon = true
hostname = "irc.freenode.org" local hostname = "irc.freenode.org"
--hostname = "127.0.0.1" --hostname = "127.0.0.1"
port = 6667 local port = 6667
nick = "lbot01" local nick = "lbot01"
chan = "##lfile01" local chan = "##lfile01"
-- this blocks until the connection is established -- this blocks until the connection is established
-- for once lets say this ok since Lsyncd didnt yet actually -- for once lets say this ok since Lsyncd didnt yet actually
-- start. -- start.
--- @diagnostic disable-next-line: undefined-global
local ircSocket, err = socket.connect(hostname, port) local ircSocket, err = socket.connect(hostname, port)
if not ircSocket then if not ircSocket then
log("Error", "Cannot connect to IRC: ", err) log("Error", "Cannot connect to IRC: ", err)

View File

@ -12,7 +12,7 @@ cwriteln( '****************************************************************' )
local tdir, srcdir, trgdir = mktemps( ) local tdir, srcdir, trgdir = mktemps( )
-- makes some startup data -- makes some startup data
churn( srcdir, 10, init ) churn( srcdir, 10, false )
local logs = { } local logs = { }
--local logs = {'-log', 'Exec', '-log', 'Delay' } --local logs = {'-log', 'Exec', '-log', 'Delay' }
@ -34,10 +34,10 @@ posix.sleep( 10 )
cwriteln( 'killing the Lsyncd daemon' ) cwriteln( 'killing the Lsyncd daemon' )
posix.kill( pid ) posix.kill( pid )
local _, exitmsg, lexitcode = posix.wait( lpid ) local _, exitmsg, lexitcode = posix.wait( pid )
cwriteln( 'Exitcode of Lsyncd = ', exitmsg, ' ', lexitcode ) cwriteln( 'Exitcode of Lsyncd = ', exitmsg, ' ', lexitcode )
result, code = execute( 'diff -r ' .. srcdir .. ' ' .. trgdir ) local result, code = execute( 'diff -r ' .. srcdir .. ' ' .. trgdir )
if result == 'exit' if result == 'exit'
then then

View File

@ -36,10 +36,10 @@ posix.sleep( 10 )
cwriteln( 'killing the Lsyncd daemon' ) cwriteln( 'killing the Lsyncd daemon' )
posix.kill( pid ) posix.kill( pid )
local _, exitmsg, lexitcode = posix.wait( lpid ) local _, exitmsg, lexitcode = posix.wait( pid )
cwriteln( 'Exitcode of Lsyncd = ', exitmsg, ' ', lexitcode ) cwriteln( 'Exitcode of Lsyncd = ', exitmsg, ' ', lexitcode )
result, code = execute( 'diff -r ' .. srcdir .. ' ' .. trgdir ) local result, code = execute( 'diff -r ' .. srcdir .. ' ' .. trgdir )
if result == 'exit' if result == 'exit'
then then

View File

@ -43,11 +43,11 @@ cwriteln( 'killing the Lsyncd daemon' )
posix.kill(pid) posix.kill(pid)
local _, exitmsg, lexitcode = posix.wait( lpid ) local _, exitmsg, lexitcode = posix.wait( pid )
cwriteln( 'Exitcode of Lsyncd = ', exitmsg, ' ', lexitcode ) cwriteln( 'Exitcode of Lsyncd = ', exitmsg, ' ', lexitcode )
result, code = execute( 'diff -r ' .. srcdir .. ' ' .. trgdir ) local result, code = execute( 'diff -r ' .. srcdir .. ' ' .. trgdir )
if result == 'exit' if result == 'exit'
then then

View File

@ -132,7 +132,7 @@ cwriteln( 'waiting for Lsyncd to remove destination' )
posix.sleep( 20 ) posix.sleep( 20 )
result, code = execute( 'diff -urN ' .. srcdir .. ' ' .. trgdir ) local result, code = execute( 'diff -urN ' .. srcdir .. ' ' .. trgdir )
if result ~= 'exit' or code ~= 0 if result ~= 'exit' or code ~= 0
then then
@ -155,7 +155,7 @@ testfiles( )
cwriteln( 'killing started Lsyncd' ) cwriteln( 'killing started Lsyncd' )
posix.kill( pid ) posix.kill( pid )
local _, exitmsg, exitcode = posix.wait( lpid ) local _, exitmsg, exitcode = posix.wait( pid )
cwriteln( 'Exitcode of Lsyncd = ', exitmsg, ' ', exitcode ); cwriteln( 'Exitcode of Lsyncd = ', exitmsg, ' ', exitcode );

View File

@ -115,7 +115,7 @@ cwriteln( 'waiting for Lsyncd to remove destination' )
posix.sleep( 5 ) posix.sleep( 5 )
result, code = execute( 'diff -urN ' .. srcdir .. ' ' .. trgdir ) local result, code = execute( 'diff -urN ' .. srcdir .. ' ' .. trgdir )
if result ~= 'exit' or code ~= 0 if result ~= 'exit' or code ~= 0
then then
@ -137,7 +137,7 @@ testfiles( )
cwriteln( 'killing started Lsyncd' ) cwriteln( 'killing started Lsyncd' )
posix.kill( pid ) posix.kill( pid )
local _, exitmsg, exitcode = posix.wait( lpid ) local _, exitmsg, exitcode = posix.wait( pid )
cwriteln( 'Exitcode of Lsyncd = ', exitmsg, ' ', exitcode ); cwriteln( 'Exitcode of Lsyncd = ', exitmsg, ' ', exitcode );

View File

@ -113,7 +113,7 @@ os.execute( 'rm -rf ' .. srcdir .. '/*' )
cwriteln( 'waiting for Lsyncd to remove destination' ) cwriteln( 'waiting for Lsyncd to remove destination' )
posix.sleep( 5 ) posix.sleep( 5 )
result, code = execute( 'diff -urN '..srcdir..' '..trgdir ) local result, code = execute( 'diff -urN '..srcdir..' '..trgdir )
if result ~= 'exit' or code ~= 0 if result ~= 'exit' or code ~= 0
then then
@ -129,7 +129,7 @@ testfiles( )
cwriteln( 'killing started Lsyncd' ) cwriteln( 'killing started Lsyncd' )
posix.kill( pid ) posix.kill( pid )
local _, exitmsg, lexitcode = posix.wait( lpid ) local _, exitmsg, lexitcode = posix.wait( pid )
cwriteln( 'Exitcode of Lsyncd = ', exitmsg, ' ', lexitcode ) cwriteln( 'Exitcode of Lsyncd = ', exitmsg, ' ', lexitcode )
posix.sleep( 1 ) posix.sleep( 1 )

View File

@ -109,7 +109,7 @@ cwriteln( 'waiting for Lsyncd to remove destination' )
posix.sleep( 5 ) posix.sleep( 5 )
result, code = execute( 'diff -urN ' .. srcdir .. ' ' .. trgdir ) local result, code = execute( 'diff -urN ' .. srcdir .. ' ' .. trgdir )
if result ~= 'exit' or code ~= 0 if result ~= 'exit' or code ~= 0
then then
@ -131,7 +131,7 @@ testfiles( )
cwriteln( 'killing started Lsyncd' ) cwriteln( 'killing started Lsyncd' )
posix.kill( pid ) posix.kill( pid )
local _, exitmsg, exitcode = posix.wait( lpid ) local _, exitmsg, exitcode = posix.wait( pid )
cwriteln( 'Exitcode of Lsyncd = ', exitmsg, ' ', exitcode ); cwriteln( 'Exitcode of Lsyncd = ', exitmsg, ' ', exitcode );

View File

@ -19,7 +19,7 @@ then
end end
cwriteln( 'starting Lsyncd' ) cwriteln( 'starting Lsyncd' )
logs = { } local logs = { }
local pid = local pid =
spawn( spawn(
'./lsyncd', './lsyncd',
@ -55,12 +55,12 @@ posix.sleep( 10 )
cwriteln( '* killing Lsyncd' ) cwriteln( '* killing Lsyncd' )
posix.kill( pid ) posix.kill( pid )
local _, exitmsg, lexitcode = posix.wait(lpid) local _, exitmsg, lexitcode = posix.wait(pid)
cwriteln( 'Exitcode of Lsyncd = ', exitmsg, ' ', lexitcode) cwriteln( 'Exitcode of Lsyncd = ', exitmsg, ' ', lexitcode)
posix.sleep( 1 ) posix.sleep( 1 )
cwriteln( '* differences:' ) cwriteln( '* differences:' )
result, code = execute( 'diff -urN ' .. srcdir .. ' ' .. trgdir ) local result, code = execute( 'diff -urN ' .. srcdir .. ' ' .. trgdir )
if result == 'exit' if result == 'exit'
then then

View File

@ -69,7 +69,7 @@ testfile( srcdir..'b' )
testfile( srcdir..'c' ) testfile( srcdir..'c' )
cwriteln( 'killing started Lsyncd' ) cwriteln( 'killing started Lsyncd' )
posix.kill( pid ) posix.kill( pid )
local _, exitmsg, lexitcode = posix.wait( lpid ) local _, exitmsg, lexitcode = posix.wait( pid )
cwriteln( 'Exitcode of Lsyncd = ', exitmsg, ' ', lexitcode) cwriteln( 'Exitcode of Lsyncd = ', exitmsg, ' ', lexitcode)
posix.sleep(1); posix.sleep(1);

View File

@ -1,3 +1,5 @@
--- @diagnostic disable: lowercase-global, need-check-nil
-- common testing environment -- common testing environment
posix = require( 'posix' ) posix = require( 'posix' )
string = require( 'string' ) string = require( 'string' )
@ -11,6 +13,7 @@ local c0='\027[0m'
-- compatibility with 5.1 -- compatibility with 5.1
if table.unpack == nil then if table.unpack == nil then
--- @diagnostic disable-next-line: deprecated
table.unpack = unpack table.unpack = unpack
end end
@ -46,8 +49,7 @@ end
-- If environment variable 'SEED' is set, -- If environment variable 'SEED' is set,
-- that one is used seed. -- that one is used seed.
-- --
local seed = os.getenv( 'SEED') or os.time( ) local seed = tonumber(os.getenv( 'SEED')) or os.time( )
math.randomseed( seed ) math.randomseed( seed )
cwriteln( 'random seed: ', seed ) cwriteln( 'random seed: ', seed )
@ -61,6 +63,10 @@ function mktempd
( ) ( )
local f = io.popen( 'mktemp -td ltest.XXX', 'r' ) local f = io.popen( 'mktemp -td ltest.XXX', 'r' )
if f == nil then
return error("can't create testing directory")
end
local s = f:read( '*a' ) local s = f:read( '*a' )
f:close( ) f:close( )