<pre style='margin:0'>
Clemens Lang (neverpanic) pushed a commit to branch gsoc17-migrate
in repository macports-base.
</pre>
<p><a href="https://github.com/macports/macports-base/commit/632e1b3813b7b3f60f8609576ad35718824cd6e8">https://github.com/macports/macports-base/commit/632e1b3813b7b3f60f8609576ad35718824cd6e8</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit 632e1b3813b7b3f60f8609576ad35718824cd6e8
</span>Author: Umesh Singla <umeshksingla@macports.org>
AuthorDate: Sat Aug 26 03:07:00 2017 +0530
<span style='display:block; white-space:pre;color:#404040;'> Make migrate accept the new format of [snapshot ports]
</span>---
src/macports1.0/migrate.tcl | 174 ++++++++++++++++++++----------------------
src/registry2.0/snapshotobj.c | 12 +--
2 files changed, 88 insertions(+), 98 deletions(-)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/macports1.0/migrate.tcl b/src/macports1.0/migrate.tcl
</span><span style='display:block; white-space:pre;color:#808080;'>index 73144fe..92df280 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/macports1.0/migrate.tcl
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/macports1.0/migrate.tcl
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -45,48 +45,14 @@ namespace eval migrate {
</span> puts $snapshot
puts [$snapshot note]
puts [$snapshot created_at]
<span style='display:block; white-space:pre;background:#ffe0e0;'>- puts [$snapshot ports]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- puts "here 2"
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return 0
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # fetch ports and variants for this snapshot
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # WILL WRITE FOR FETCHING AFTER DISCUSSING WITH BRAD
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # ASSUMING I GET THE FINAL PORTLIST FOR NOW
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # $portlist
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set portlist [registry::entry imaged]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- foreach port $portlist {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- #puts [$port name]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set portlist1 [$snapshot ports]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ puts $portlist1
</span>
<span style='display:block; white-space:pre;background:#ffe0e0;'>- puts "here"
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- puts
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ puts "\nhere 2\n"
</span>
<span style='display:block; white-space:pre;background:#ffe0e0;'>- #set portlist1 [sort_portlist_by_dependendents $portlist]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # uninstall_installed $portlist1
</span>
<span style='display:block; white-space:pre;background:#ffe0e0;'>- puts "here1"
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- puts ""
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set portlist2 [sort_ports $portlist]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- puts "here2"
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # foreach port $portlist1 {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # puts $port
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # puts
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- foreach port $portlist2 {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- #puts [lindex $port 0]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- #uninstall_installed $portlist
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return 0
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # recover_ports_state $portlist
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ recover_ports_state $portlist1
</span>
# TODO: CLEAN PARTIAL BUILDS STEP HERE
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -110,6 +76,15 @@ namespace eval migrate {
</span> # TODO: error handling, if any?
array set portInfo [lindex $portSearchResult 1]
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[catch {set mport [mportopen $portInfo(porturl) [list subport $portInfo(name)] $variantInfo]} result]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ global errorInfo
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ puts stderr "$errorInfo"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return -code error "Unable to open port '$portName': $result"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ array unset portInfo
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ array set portInfo [mportinfo $mport]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ mportclose $mport
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> set dependencyTypes { depends_fetch depends_extract depends_build depends_lib depends_run }
foreach dependencyType $dependencyTypes {
if {[info exists portInfo($dependencyType)] && [string length $portInfo($dependencyType)] > 0} {
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -131,19 +106,36 @@ namespace eval migrate {
</span>
foreach port $portlist {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- #puts "in - "
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- #puts $port
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set name [$port name]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set variants [$port variants]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set name [lindex $port 0]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set requested [lindex $port 1]
</span> set active 0
<span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if {[$port state] eq "installed"} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[lindex $port 2] eq "installed"} {
</span> set active 1
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- #puts "$name $variants $active"
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set variantstr [lindex $port 3]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {$variantstr eq "(null)"} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set variantstr ""
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set variants ""
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[info exists variantstr]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ while 1 {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set nextplus [string last + $variantstr]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set nextminus [string last - $variantstr]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {$nextplus > $nextminus} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set next $nextplus
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set sign +
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set next $nextminus
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set sign -
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {$next == -1} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ break
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set v [string range $variantstr [expr $next + 1] end]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lappend variants $v $sign
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set variantstr [string range $variantstr 0 [expr $next - 1]]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span> if {![info exists port_in_list($name)]} {
set port_in_list($name) 1
set port_installed($name) 0
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -154,16 +146,11 @@ namespace eval migrate {
</span> if {![info exists port_deps(${name},${variants})]} {
set port_deps(${name},${variants}) [port_dependencies $name $variants]
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- #puts "$port_deps(${name},$variants)"
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span> lappend newList [list $name $variants $active]
}
set operationList [list]
<span style='display:block; white-space:pre;background:#ffe0e0;'>- puts
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span> while {[llength $newList] > 0} {
set oldLen [llength $newList]
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -171,9 +158,6 @@ namespace eval migrate {
</span> foreach port $newList {
foreach {name variants active} $port break
<span style='display:block; white-space:pre;background:#ffe0e0;'>- #puts "out - "
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- #puts "$name $variants $active"
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span> if {$active && $port_installed($name) < ($port_in_list($name) - 1)} {
continue
}
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -185,7 +169,6 @@ namespace eval migrate {
</span> }
}
if {$installable} {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- #puts "i'm being installed: $name"
</span> lappend operationList [list $name $variants $active]
incr port_installed($name)
set index [lsearch $newList [list $name $variants $active]]
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -193,19 +176,17 @@ namespace eval migrate {
</span> }
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- #puts "lengths: $oldLen [llength $newList]"
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span> if {[llength $newList] == $oldLen} {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- return -code error "stuck in loop"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return -code error "Stuck in loop"
</span> }
}
return $operationList
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- proc portlist_sort_dependencies_later { portlist } {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ proc portlist_sort_dependencies_later {portlist} {
</span>
<span style='display:block; white-space:pre;background:#ffe0e0;'>- # Sorts a list of port references such that dependents come before
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # Sorts a list of port references such that ports come before
</span> # their dependencies.
#
# Args:
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -215,17 +196,17 @@ namespace eval migrate {
</span> # the list in dependency-sorted order
foreach port $portlist {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- array set pvals $port
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- lappend entries($pvals(name)) $port
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set portname [$port name]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lappend entries($portname) $port
</span>
# Avoid adding ports in loop
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {![info exists dependents($pvals(name))]} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set dependents($pvals(name)) {}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {![info exists dependents($portname)]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set dependents($portname) {}
</span> foreach result [$port dependents] {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- lappend dependents($pvals(name)) [$result name]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lappend dependents($portname) [$result name]
</span> }
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- array unset pvals
</span> }
set ret {}
foreach port $portlist {
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -239,8 +220,8 @@ namespace eval migrate {
</span> if {![info exists seen($port)]} {
set seen($port) 1
upvar 1 $up_entries entries $up_dependents dependents $up_retlist retlist
<span style='display:block; white-space:pre;background:#ffe0e0;'>- array set pvals $p
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- foreach dependent $dependents($pvals(name)) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set name [$port name]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach dependent $dependents($name) {
</span> if {[info exists entries($dependent)]} {
foreach entry $entries($dependent) {
portlist_sort_dependencies_later_helper $entry entries dependents seen retlist
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -251,31 +232,25 @@ namespace eval migrate {
</span> }
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- proc uninstall_installed { portlist } {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ proc uninstall_installed {portlist} {
</span>
set portlist [portlist_sort_dependencies_later $portlist]
<span style='display:block; white-space:pre;background:#ffe0e0;'>- foreach port $portlist {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- puts "[$port name] [$port state]"
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return 0
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span> if {[info exists macports::ui_options(questions_yesno)]} {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set retvalue [$macports::ui_options(questions_yesno) "Restoring a snapshot will first uninstall all the installed ports.
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- Would you like to continue?" {n} 0]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set msg "Migration will first uninstall all the installed ports first."
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set retvalue [$macports::ui_options(questions_yesno) $msg "MigrationPrompt" "" {y} 0 "Would you like to continue?"]
</span>
if {$retvalue == 0} {
foreach port $portlist {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set name [$port name]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- ui_msg "Uninstalling: $name"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set portname [$port name]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_msg "Uninstalling: $portname"
</span>
try -pass_signal {
# 'registry_uninstall' takes name, version, revision, variants and an options list for a port
<span style='display:block; white-space:pre;background:#ffe0e0;'>- registry_uninstall::uninstall [$port name] [$port version] [$port revision] [$port] variants {}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ registry_uninstall::uninstall [$port name] [$port version] [$port revision] [$port variants] {}
</span> } catch {{*} eCode eMessage} {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- ui_error "Error uninstalling $name: $eMessage"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_error "Error uninstalling $portname: $eMessage"
</span> }
}
} else {
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -286,22 +261,40 @@ namespace eval migrate {
</span> return 0
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- proc recover_ports_state {portList} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ proc recover_ports_state {portlist} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set sorted_portlist [portlist_sort_dependencies_first $portlist]
</span>
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set sorted_portlist [portlist_sort_dependencies_first $portList]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach port $sorted_portlist {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ puts "$port"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ puts "MacPorts Version: [macports::version]"
</span> foreach port $sorted_portlist {
set name [string trim [lindex $port 0]]
set variations [lindex $port 1]
set active [lindex $port 2]
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {$active} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {!$active} {
</span> set target install
} else {
set target activate
}
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ puts "$name $variations $active $target"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[catch {set res [mportlookup $name]} result]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ global errorInfo
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ui_debug "$errorInfo"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return -code error "lookup of portname $name failed: $result"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[llength $res] < 2} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # not in the index, but we already warned about that earlier
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ continue
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> array unset portinfo
array set portinfo [lindex $res 1]
set porturl $portinfo(porturl)
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -309,8 +302,6 @@ namespace eval migrate {
</span> # TODO: error handling, if any?
set workername [mportopen $porturl [list subport $portinfo(name)] $variations]
<span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # TODO: instead of mportexec, look for some API?
</span> if {[catch {set result [mportexec $workername $target]} result]} {
global errorInfo
mportclose $workername
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -319,8 +310,7 @@ namespace eval migrate {
</span> } else {
mportclose $workername
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- # TODO: deps active?
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # TODO: dependencies active?
</span> }
}
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/registry2.0/snapshotobj.c b/src/registry2.0/snapshotobj.c
</span><span style='display:block; white-space:pre;color:#808080;'>index 957b691..5b94b52 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/registry2.0/snapshotobj.c
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/registry2.0/snapshotobj.c
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -75,6 +75,7 @@ static int snapshot_obj_prop(Tcl_Interp* interp, reg_snapshot* snapshot, int obj
</span> }
return TCL_ERROR;
}
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ return TCL_ERROR;
</span> }
/* ${snapshot} ports */
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -97,21 +98,18 @@ static int snapshot_obj_ports(Tcl_Interp* interp, reg_snapshot* snapshot, int ob
</span> reg_error error;
int port_count = reg_snapshot_ports_get(snapshot, &ports, &error);
if (port_count >= 0) {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- char* portstr = NULL;
</span> char* portstrs[port_count + 1];
int i;
for(i = 0; i < port_count; i++){
port* current_port = ports[i];
<span style='display:block; white-space:pre;background:#ffe0e0;'>- portstr = NULL;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if (asprintf(&portstr, "%s %d %s %s",
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ portstrs[i] = NULL;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (asprintf(&portstrs[i], "%s %d %s %s",
</span> current_port->name,
current_port->requested,
current_port->state,
current_port->variants) < 0) {
return TCL_ERROR;
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- portstrs[i] = portstr;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- free(portstr);
</span> }
Tcl_Obj** objs;
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -129,9 +127,11 @@ static int snapshot_obj_ports(Tcl_Interp* interp, reg_snapshot* snapshot, int ob
</span> }
}
return registry_failed(interp, &error);
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ } else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return TCL_ERROR;
</span> }
<span style='display:block; white-space:pre;background:#ffe0e0;'>- return TCL_ERROR;
</span> }
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ return TCL_ERROR;
</span> }
typedef struct {
</pre><pre style='margin:0'>
</pre>