Skip to content

Commit f4a5a32

Browse files
committed
CP-37241: Avoid using List.hd
Signed-off-by: Lin Liu <[email protected]>
1 parent 0f514ae commit f4a5a32

File tree

6 files changed

+13
-8
lines changed

6 files changed

+13
-8
lines changed

ocaml/tests/test_data/repository_pkg_of_fullname_all

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,6 @@ intel-igb-5.3.5.20-2.xs8.x86_64
253253
nss-pem-1.0.3-4.el7.x86_64
254254
gssproxy-0.7.0-17.el7.x86_64
255255
nss-sysinit-3.36.0-7.el7_5.x86_64
256-
pbis-open-8.2.3-1.7.8.xs8.x86_64
257256
mailx-12.5-19.el7.x86_64
258257
system-config-firewall-base-1.2.29-10.el7.noarch
259258
libgomp-4.8.5-28.el7_5.1.x86_64
@@ -464,7 +463,6 @@ broadcom-bnxt-en-1.10.0_216.0.119.1-2.xs8.x86_64
464463
tar-1.26-34.el7.x86_64
465464
avago-megaraid-sas-07.713.01.00+rc1-2.xs8.x86_64
466465
nss-softokn-3.36.0-5.el7_5.x86_64
467-
pbis-open-upgrade-8.2.2-3.xs8.x86_64
468466
nss-tools-3.36.0-7.el7_5.x86_64
469467
forkexecd-1.22.0-7.xs8.x86_64
470468
libunistring-0.9.3-9.el7.x86_64

ocaml/xapi/extauth.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ module Ext_auth = struct
4444
| "PAM" ->
4545
(*pam/nss unix services*)
4646
Authx.AuthX.methods
47-
(* the PBIS authentication plugin *)
47+
(* the external authentication plugin *)
4848
| "AD" ->
4949
(*windows active directory*)
5050
Extauth_ad.methods()

ocaml/xapi/extauth_plugin_ADwinbind.ml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,15 +380,22 @@ let query_domain_workgroup ~domain ~db_workgroup =
380380
let err_msg =
381381
Printf.sprintf "Failed to look up domain %s workgroup" domain
382382
in
383+
let hd msg = function
384+
| [] ->
385+
error "%s" msg ;
386+
raise (Auth_service_error (E_LOOKUP, msg))
387+
| h :: _ ->
388+
h
389+
in
383390
try
384391
let kdc =
385392
Helpers.call_script ~log_output:On_failure net_cmd
386393
["lookup"; "kdc"; domain; "-d"; debug_level]
387394
(* Result like 10.71.212.25:88\n10.62.1.25:88\n*)
388395
|> String.split_on_char '\n'
389-
|> List.hd
396+
|> hd "lookup kdc return invalid result"
390397
|> String.split_on_char ':'
391-
|> List.hd
398+
|> hd "kdc has invalid address"
392399
in
393400

394401
let lines =

ocaml/xapi/xapi.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1364,7 +1364,7 @@ let server_init () =
13641364
, fun () ->
13651365
call_extauth_hook_script_before_xapi_initialize ~__context
13661366
)
1367-
; ( "Initializing lwsmd service"
1367+
; ( "Initializing AD external auth service"
13681368
, [Startup.NoExnRaising]
13691369
, fun () -> Extauth_ad.init_service ~__context )
13701370
; ( "Calling on_xapi_initialize event hook in the external \

ocaml/xapi/xapi_host.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1217,7 +1217,7 @@ let set_hostname_live ~__context ~host ~hostname =
12171217
let current_auth_type =
12181218
Db.Host.get_external_auth_type ~__context ~self:host
12191219
in
1220-
(* the AD/Likewise extauth plugin is incompatible with a hostname change *)
1220+
(* the AD extauth plugin is incompatible with a hostname change *)
12211221
( if current_auth_type = Xapi_globs.auth_type_AD then
12221222
let current_service_name =
12231223
Db.Host.get_external_auth_service_name ~__context ~self:host

quality-gate.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
set -e
44

55
list-hd () {
6-
N=297
6+
N=295
77
LIST_HD=$(git grep -r --count 'List.hd' -- **/*.ml | cut -d ':' -f 2 | paste -sd+ - | bc)
88
if [ "$LIST_HD" -eq "$N" ]; then
99
echo "OK counted $LIST_HD usages"

0 commit comments

Comments
 (0)