base-files: generalize ucidef_set_network_device
authorChristian Marangi <ansuelsmth@gmail.com>
Thu, 9 Nov 2023 14:11:50 +0000 (15:11 +0100)
committerChristian Marangi <ansuelsmth@gmail.com>
Fri, 10 Nov 2023 11:30:33 +0000 (12:30 +0100)
Generalize ucidef_set_network_device functions to use a more generic
_ucidef_set_network_device_common that takes as args the option and the
value to apply instead of hardcoding.

This is to reduce duplicated code in preparation for addition of
additional option for board.d usage.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
package/base-files/files/lib/functions/uci-defaults.sh

index 6f395ec24b2a4ec6236d256e05e6a56faa81c91c..d40f4354ad5801aee5c4db7725036e078e93b748 100644 (file)
@@ -106,20 +106,20 @@ ucidef_set_bridge_mac() {
        json_select ..
 }
 
-ucidef_set_network_device_mac() {
+_ucidef_set_network_device_common() {
        json_select_object "network_device"
        json_select_object "${1}"
-       json_add_string macaddr "${2}"
+       json_add_string "${2}" "${3}"
        json_select ..
        json_select ..
 }
 
+ucidef_set_network_device_mac() {
+       _ucidef_set_network_device_common $1 macaddr $2
+}
+
 ucidef_set_network_device_path() {
-       json_select_object "network_device"
-       json_select_object "$1"
-       json_add_string path "$2"
-       json_select ..
-       json_select ..
+       _ucidef_set_network_device_common $1 path $2
 }
 
 _ucidef_add_switch_port() {